Sep-03-2020, 12:40 PM
(This post was last modified: Sep-03-2020, 12:41 PM by deanhystad.)
I'm not sure if you could pack in any more errors into such a short line of code.
x = [2593.75, 2457.42, 2593.75, 2457.42]
diff = abs (x(1)-(2))Start with x is a list. You cannot do x(). You can do x[]. x[1] is a dictionary.
diff = abs (x[1]-(2))Now (2) is the number 2. So this tries to subtract the number 2 from a dictionary. That is not allowed. I am going to assume you want to subtract the X number in dictionary x[1] from the X number in dictionary x[2]
diff = abs (x[1]- x[2])This is closer but still wring because it subtracts a dictionary from a dictionary and you want to subtract the 'X' attributes.
diff = abs (x[1].X- x[2].X)There is probably a reason you are using a list of dictionaries that is not discussed in your post instead of just putting the numbers in the list like this.
x = [2593.75, 2457.42, 2593.75, 2457.42]