‘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
No comments:
Post a Comment