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


Groups > comp.lang.python > #62683 > unrolled thread

Re: Variables in a loop, Newby question

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2013-12-24 17:23 +0100
Last post2013-12-27 14:40 -0800
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  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

#62683 — Re: Variables in a loop, Newby question

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2013-12-24 17:23 +0100
SubjectRe: Variables in a loop, Newby question
Message-ID<mailman.4597.1387902231.18130.python-list@python.org>
----- 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.

[toc] | [next] | [standalone]


#62827

Fromvanommen.robert@gmail.com
Date2013-12-27 14:40 -0800
Message-ID<57342661-b593-43a8-83a2-59f846568456@googlegroups.com>
In reply to#62683
Op dinsdag 24 december 2013 17:23:43 UTC+1 schreef Jean-Michel Pichavant:
> ----- 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.

This was the information I was looking for and what my first question was about. Got this working, Thank you.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web