Several questions related to the same issue have been posted, but do not find a solution to my problem. I would like to get the output of my loop (list of 2000 floats) into a python list. I am getting the "variable non iterable error" because I am not managing to call each of the elements of the output in the right way to be written into a list.
Other attempts, like converting to a list inside the loop, give me a list per element, when I need only one list with all the elements inside.
This is my code:
for i in range(x):
timedelta= (function(i)) #datetime.timedelta elements
pos_time = (i, function(i)) #tuple of an integer and a float
time = pos_time[1]
print time
If I finish here I get the list of values I need:
3.5
2.04
6.6
4.02
...
If I continue inside the loop:
times = []
for time in range(x):
times.append(time)
then I get a list from consecutive values, not really the output from the loop. What I need is a list like:
times = [3.5,2.04,6.6,4.02]
I would appreciate your help very much.