Len() and str()


#1

In exercise 9, it states that len() and str() don’t use dot notation since they can be used with other data types, unlike .upper() and .lower() which only work with strings. How can len() be used with other data types? I understand that str() can be used on for example an integer like 7 to make it the string “7”, but for len() I tried finding the length of a number and it gave an error. I expected if I did len(1025) it would return 4 since that is the number of characters in that number. I was wrong, but then how can len() be used with other data types?

Strings and Console Output


#2

other data types is something different then all other data types, len() works perfectly fine on lists for example:

len([1, 2, 3])

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.