len()

len(iterable )
iterable :input iterable or string or any sequence
Return the number of elements present, for string we can get number of chars in the string.

Using string

my_str='plus2net.com'
print(len(my_str)) #12
Using list
my_list=['Welcome','to','plus2net']
print(len(my_list)) # 3
my_list=[2,3,1,5]
print(len(my_list)) #4
Using tuple
my_tuple=(5,2,3,6)
print(len(my_tuple)) #4
Using Dictionary

Output depends on Keys of the Dictionary ( Not Values ).
my_dict={1:'A',2:'B',3:'C'}
print(len(my_dict)) # 3 
Using set
my_set={2,4,1,5}
print(len(my_set)) # 4
Using frozenset()
my_set={4,3,2,1,7}
my_set=frozenset(my_set)
print(len(my_set))  # 5 
max() Iterator any()


Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer