Friday, 18 December 2020

Python: Length (or) number of elements in the list

‘len(list_name)’ function return number of elements in the list.

 

list_length.py

country_names = ["India", "Australia", "Sri Lanka", "Itali"]

print(f"Elements list : {country_names}")
print(f"length : {len(country_names)}")

 

Output

$python3 list_length.py 
Elements list : ['India', 'Australia', 'Sri Lanka', 'Itali']
length : 4

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment