I want to append dictionary values to a list from a for loop, though it is only picking up the last value. Please advise, here is my code:
for line in obj:
test = float(line['value'])
print(test)
a = []
a.append(test)
Huh! You have messed up the indentation. Indentation is VERY IMPORTANT in python. a list is outside the for-loop hence it would only have the last value of test. IT should be inside the for-loop.
It should be like this -
a = []
for line in obj:
test = float(line['value'])
print(test)
a.append(test)
print a