python trap

What will this code print?

for item in ('aaa'): print item


The result is:

a
a
a

I think you expected the following as the result:

aaa

I was near reporting a bug, but, fortunately, realized, that "('aaa')" is actually not a list, but a string in parenthesis. The correct way to get the desired result is:

for item in ('aaa',): print item
Categories: python

Updated: