String length ... len(str)

Bernard Delmée bdelmee at advalvas.REMOVEME.be
Wed Dec 3 19:13:59 EST 2003


> Why is len(str1) = 4  and len(str2) = 3?

Because str1 is a string whereas str2 is a tuple.
Both are sequences whose size is returned by len().
You probably meant str2 = "here" + "we" + "are"
If you ask "type(str2)" at the python prompt, you'll
see exactly what's going on.

Cheers,

Bernard.





More information about the Python-list mailing list