Hi all. Look at this snippet of code.
[color=blue][color=green][color=darkred]
>>> l = ['a','b','c','d']
>>> l[/color][/color][/color]
['a', 'b', 'c', 'd'][color=blue][color=green][color=darkred]
>>> l[0][0][0][/color][/color][/color]
'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??
[color=blue][color=green][color=darkred]
>>> l = [1,2,3]
>>> l[0][/color][/color][/color]
1[color=blue][color=green][color=darkred]
>>> l[0][0][/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#244>" , line 1, in -toplevel-
l[0][0]
TypeError: unsubscriptable object[color=blue][color=green][color=darkred]
>>> l[0][/color][/color][/color]
1[color=blue][color=green][color=darkred]
>>> 1[0][/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#246>" , line 1, in -toplevel-
1[0]
TypeError: unsubscriptable object[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
The compiler reports unsubscriptable object ?? confused , dazzled i am ???!!??
The same list now holds integer instead of strings and l[0][0][0]
which worked fine earlier on strings doesn't seem to work on
integers???
Any help is greatly appreciated.
--
cheers,
Ishwor Gurung
[color=blue][color=green][color=darkred]
>>> l = ['a','b','c','d']
>>> l[/color][/color][/color]
['a', 'b', 'c', 'd'][color=blue][color=green][color=darkred]
>>> l[0][0][0][/color][/color][/color]
'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??
[color=blue][color=green][color=darkred]
>>> l = [1,2,3]
>>> l[0][/color][/color][/color]
1[color=blue][color=green][color=darkred]
>>> l[0][0][/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#244>" , line 1, in -toplevel-
l[0][0]
TypeError: unsubscriptable object[color=blue][color=green][color=darkred]
>>> l[0][/color][/color][/color]
1[color=blue][color=green][color=darkred]
>>> 1[0][/color][/color][/color]
Traceback (most recent call last):
File "<pyshell#246>" , line 1, in -toplevel-
1[0]
TypeError: unsubscriptable object[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
The compiler reports unsubscriptable object ?? confused , dazzled i am ???!!??
The same list now holds integer instead of strings and l[0][0][0]
which worked fine earlier on strings doesn't seem to work on
integers???
Any help is greatly appreciated.
--
cheers,
Ishwor Gurung
Comment