['a', 'b'][True] results 'b' But how?

kath nitte.sudhir at gmail.com
Thu Jul 5 02:54:41 EDT 2007


Hi,

Can any one please tell me how is the following code is working?
['a','b'] is a list of string, and [True] is list of boolean value.
How is it making effect....?
<code Python24>

>>> ['a','b] [True]
'b'
>>> ['a','b'] [False]
'a'
>>> ['a','b']['some_string' == r'some_string']
'b'
>>> ['a','b']['some_string' == r'somestring']
'a'

<code>


Thanks in advance,
regards,
kath.




More information about the Python-list mailing list