Сергій wrote:
> suppose I need to create 1000 000 variables
> var_1, var_2, .... var_1000000
> how to do this using for?
> (something like
> for i in range(1000000):
> ___var_

Rather than creating 1000000 variables, create a list with 1000000 values.
data = []
for i in range(1000000):
data.append(i*i) # or whatever data you want in your variables

This can be very nicely abbreviated with a list comprehension:
data = [ i*i for i in range(1000000) ]

In general, when you think you need to create a bunch of variables with 
repetive names, you should probably use a list or dictionary instead.

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to