Jun-10-2020, 08:09 AM
Thanks Bowlofred, very instructive !
Although the two versions of k1 look similar when printed, clearly Python sees them differently.
Your suggestion solves the problem, and I am using eval to convert the string to tuple as at line 26 attached.
Thanks again, brilliantly simple.
Astrikor
Although the two versions of k1 look similar when printed, clearly Python sees them differently.
Your suggestion solves the problem, and I am using eval to convert the string to tuple as at line 26 attached.
Thanks again, brilliantly simple.
Astrikor
import gradients print("Part A - direct input to Trend function") k = (2, 4,6,8) Gradient = gradients.Trend(k) print() print("Gradient = ",Gradient) print() print("######################") print() print() print("Part B - indirect input to Trend function") print() print("Create example data list k") x = k = 2 while x < 8: x = x + 2 k = k,x print("k2 = ",k) # remove all brackets from k: k = str(k).replace('(', '').replace(')', '') print("k3 = ",k) k = "({})".format(k) print("k4 formatted to match direct newdata : ",k) print() k = eval(k)#(converts string to tuple) print("k5 Converted to tuple = ", k) #send data to Trend function: Gradient = gradients.Trend(k) print() print("Gradient = ",Gradient)