Patrick Useldinger a écrit :
remi wrote:

Hello,

I have got a list like : mylist = ['item 1', 'item 2',....'item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is finite ;-)
Any ideas ?
Thanks a lot.
Rémi.


Use a dictionary: variable['s_1']= mylist.pop(), variable['s_2'] = mylist.pop() ...

Ok thanks but is there a way to automate this variable numbering ? Such like :
i = 0
for i <=len(mylist)
s_i=mylist[i]
i = i +1
or as you suggest :
i = 0
while i<=len(mylist)
variable['s_i']=mylist.pop()
i = i+1
Thanks.
Rémi.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to