List vs. Tuple
Matthew Hirsch
meh9 at cornell.edu
Thu Oct 7 12:10:01 EDT 1999
Thanks guys. It makes sense now.
Matthew Hirsch wrote:
> 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