Greetings,
I am just now learning python and am trying to use the index function with variables.

list1 = ['pig', 'horse', 'moose']
list2 =  ['62327', '49123', '79115']
a = list2[list1.index('horse')]
print a
>49123

   -works fine. But

list1 = ['pig', 'horse', 'moose']
list2 =  ['62327', '49123', '79115']
n = 2
s2 = "list" + `n`
a = s2[list1.index('horse')]
print a

  -does not work

I'd like to use the index function in a loop updating the file names by adding a number to that name with each cycle. But can't get to first base.

Thank you,

   Rusty Scalf

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to