Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62683

Re: Variables in a loop, Newby question

Date 2013-12-24 17:23 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: Variables in a loop, Newby question
Newsgroups comp.lang.python
Message-ID <mailman.4597.1387902231.18130.python-list@python.org> (permalink)

Show all headers | View raw


----- 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.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Variables in a loop, Newby question Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-12-24 17:23 +0100
  Re: Variables in a loop, Newby question vanommen.robert@gmail.com - 2013-12-27 14:40 -0800

csiph-web