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
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
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
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