variable name using a for

Cameron Laird claird at lairds.com
Tue Mar 2 14:02:33 EST 2004


In article <4044d7f3$0$4664$626a14ce at news.free.fr>,
Alex <alx5962NOSPAN at yahoo.com> wrote:
>Hi
>I would like to create a variable (a string) in 'for' statement with a name
>linked to the for value.
>Like this:
>for y in range(nbSujets):
>    name + str(y) = 'abc'
>
>But it doesn't work with Python.... I read the official documentation but I
>was not able to find infos about this..
>How to make this works please?
			.
			.
			.
While you can do that, you shouldn't.  Unless
there are requirements you haven't explained,
you're better off exploiting a dictionary:

  name = {}
  for y in range(nbSujects):
      name[y] = 'abc'
-- 

Cameron Laird <claird at phaseit.net>
Business:  http://www.Phaseit.net



More information about the Python-list mailing list