Return the number of items in a list:
mylist = ["apple", "banana", "cherry"]
x = len(mylist)
The len()
function returns the number of items in an object.
When the object is a string, the len()
function returns the number of characters in the string.
Return the number of characters in a string:
mylist = "Hello"
x = len(mylist)
Track your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4