+ 1
Help me, please with the loop
Hello. Can anybody help me with this question: How can I assign values to the variables in the loop? I mean, I want to get some variables like a1=..., a2=..., a3=..., a4=... in the loop (i from 1 to 4)?
5 ответов
+ 3
Link your code here so people can see clearly what's the problem and offer solutions :)
+ 1
for i in range(1,5):
a[i] = i*i
i will take the values from 1-4
so, a[i] means a[1] ... a[4] and then you can do the assignment
+ 1
Try creating an array.
0
i've tried,but there is an error:
TypeError: 'str' object does not support item assignment