List vs. Tuple

Stidolph, David stidolph at origin.ea.com
Thu Oct 7 12:18:38 EDT 1999


try

tuple = ('abcd',)

-----Original Message-----
From: Matthew Hirsch [mailto:meh9 at cornell.edu]
Sent: Thursday, October 07, 1999 10:48 AM
To: python-list at python.org
Subject: List vs. Tuple


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


-- 
http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list