10.3. List Length

As with strings, the function len returns the length of a list (the number of items in the list).

 
1
a_list: [str]
2
a_list =  ["Brie", "Roquefort", "Pol le Veq"]
3
print(str(len(a_list)))
4

(chp09_01a)

Check your understanding

list-3-1: What is printed by the following statements?

a_list: [int]
a_list = [3, 67, 14, 31, 53]
print(str(len(a_list)))



You have attempted 1 of 3 activities on this page
Next Section - 10.4. Accessing Elements