List vs. Tuple

Matthew Hirsch meh9 at cornell.edu
Thu Oct 7 11:48:21 EDT 1999


Hi All,

Can someone explain to me why if there is only a string in a list/tuple
they behave differently when looped through.  For example,

>>> list=['abcd']
>>> tuple=('abcd')
>>> for x in list:
...     print x
...
abcd
>>> for x in tuple:
...     print x
...
a
b
c
d
>>>

Shouldn't the second loop also print 'abcd'?

Thanks for your help,
Matt





More information about the Python-list mailing list