Name

len()

Examples
message = "It was the best of strings, it was the worst of strings."
print(len(message)) # Prints 56

items = ["gorgonzola", "mozzarella", "edam", "gouda"]
print(len(items)) # Prints 4

capitals = {'NY': 'Albany', 'CA': 'Sacramento', 'FL': 'Tallahassee'}
print(len(capitals)) # Prints 3
Description Returns the length of its parameter. The meaning of "length" varies from one type to the next. For strings, len() returns the number of characters in the string. For dictionaries, it returns the number of keys in the dictionary. For other sequences and collections (like lists, tuples and sets), it returns the number of items in the sequence or collection.
Syntax
len(a)
Parameters
athe object (usually a string, list or dictionary) whose length you want to determine
Related list()
string
Dictionary
Updated on Tue Jul 11 06:52:23 2017.
Creative Commons License