Can someone please explain the following to me:
[color=blue][color=green][color=darkred]
>>> str1 = "here"
>>> str2 = "here", "we", "are"
>>> len(str1)[/color][/color][/color]
4[color=blue][color=green][color=darkred]
>>> len(str2)[/color][/color][/color]
3
Why is len(str1) = 4 and len(str2) = 3?
If we were to say it's because the len() functions returns the number of elements in a string, then
len(str1) should be = 1
It's a little confusing.
Thanks,
Jeff
[color=blue][color=green][color=darkred]
>>> str1 = "here"
>>> str2 = "here", "we", "are"
>>> len(str1)[/color][/color][/color]
4[color=blue][color=green][color=darkred]
>>> len(str2)[/color][/color][/color]
3
Why is len(str1) = 4 and len(str2) = 3?
If we were to say it's because the len() functions returns the number of elements in a string, then
len(str1) should be = 1
It's a little confusing.
Thanks,
Jeff
Comment