Op 2004-12-23, Ishwor schreef <[EMAIL PROTECTED]>: > Hi all. Look at this snippet of code. > >>>> l = ['a','b','c','d'] >>>> l > ['a', 'b', 'c', 'd'] >>>> l[0][0][0] > 'a' > It prints the value 'a'. Fine so far :-) > l[0] ---> 'a' . > l[0][0]---> 'a'[0] --> 'a'. > l[0][0][0] ---> 'a'[0][0] --> 'a'[0] --> 'a' > > Now why doesnt this list which holds integer seem to work??
Because this only works with strings. String is the only object in python which has an implied equivallence between an element and a squence of one. So one character is a string and a string is a sequence of characters. So 'a'[0] is again 'a' which can again be indexed by 0 as many times as you want. I think python would have been more consistent if strings would have been tuples of chars and maybe implied an equivalence between whatever object and a singleton of that object. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list