help wanted with list

2009-09-24 Thread Xavier Lapointe
Not sure I understand well, but let say I did.. list[list.index('a')+1] Le 14:59, Ahmed Shamim a écrit : list = [ 'a', '1', 'b', '2'] what would be the logic, if I input a to get output 1. -- http://mail.python.org/mailman/listinfo/python-list

Re: help wanted with list

2009-09-24 Thread Simon Brunning
2009/9/24 Ahmed Shamim : > list = [ 'a', '1', 'b', '2'] > what would be the logic, if I input a to get output 1. Turn it into a dictionary first: >>> mylist = [ 'a', '1', 'b', '2'] >>> mydict = dict(zip(mylist[::2], mylist[1::2])) >>> mydict['a'] '1' -- Cheers, Simon B. -- http://mail.python.o

Re: help wanted with list

2009-09-24 Thread Iuri
You should use a dictionary. dic = {'a':1, 'b':2} Use dic['a'] to get output 1. []s iurisilvio On Thu, Sep 24, 2009 at 5:31 PM, Ahmed Shamim wrote: > list = [ 'a', '1', 'b', '2'] > what would be the logic, if I input a to get output 1. > -- > http://mail.python.org/mailman/listinfo/python-lis

help wanted with list

2009-09-24 Thread Ahmed Shamim
list = [ 'a', '1', 'b', '2'] what would be the logic, if I input a to get output 1. -- http://mail.python.org/mailman/listinfo/python-list