kath wrote: > Hi, > > Can any one please tell me how is the following code is working? > ['a','b'] is a list of string
Yes. > and [True] is list of boolean value. No. It's the subscription operator applied to the list of strings. a = ['a', 'b'] a[True] may be clearer. > How is it making effect....? >>> int(True) 1 >>> int(False) 0 >>> isinstance(True, int) True >>> bool.__bases__ (<type 'int'>,) > <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> -- rbh -- http://mail.python.org/mailman/listinfo/python-list