I want to assign for loop output values to variables in Python.
onetoten = range(1,5)
for count in onetoten:
print (count)
The output of above for loop is as below
1
2
3
4
I want to assign this output to a list of variables like s1 = 1
, s2 = 2
, s3 =3
and s4 = 4
.
But there is no specific number that the list will be till 4. It may vary based on previous output in the script. So as per output of for loop the number of variable also must increased or based on number of output the variables should be used. Please help on this.
I asked same type of question earlier where i got a response to use enumerate but this is not exactly python and i am using the script in Jython so i don't have enumerate in Jython.