Assigning names in Python
Hi. I'm having a problem with a Python program I'm trying to write, and I was wondering if any of you could help. I guess it's a pretty elementary question, but I'm a programming newbie, so there you go.
I have a for loop in my program and I would like on each iteration to assign a name. So, for example, the first time through I want the statement x1=some_function(1), the second x2=some_function(2) etc. I realise that I can't just write
for i in range(y):
xi=some_function(i)
as that will just keep assigning xi. So I'd really like to be able to write something like
for i in range(y):
'x'+str(i)=some_function(i)
but that that's not allowed. What's the best way round this problem?
|