Variables in a loop, Newby question

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Dec 24 17:23:43 CET 2013


----- Original Message -----
> Hello, for the first time I'm trying te create a little Python
> program. (on a raspberri Pi)
> 
> I don't understand the handling of variables in a loop with Python.
> 
> 
> Lets say i want something like this.
> 
> x = 1
> while x <> 10
> 	var x = x
> 	x = x + 1
> 
> The results must be:
> 
> var1 = 1
> var2 = 2
> 
> enz. until var9 = 9
> 
> How do i program this in python?

Short story, cause it's almost xmas eve :D:

python 2.5:

var = {}
for i in range(10):
  var[i] = i

print var[1]
print var[2]
print var

var here is a dictionary. I suggest that you read through the python tutorial :)

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list