Thursday 18 November 2021

Python: len(): Get number of items in the dictionary

‘len(s)’ function is used to get the length of the object. Here the argument ‘s’ can be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).

 

len_dictionary.py

employees={1:{"Krishna", "G"}, 2:{"Prithi", "Nair"}, 3: {"Mohan", "Shekkappa"}}

print('len(employees) : ', len(employees))

 

Output

len(employees) :  3

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment