10.3. List LengthΒΆ

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

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)))
    
  • 4
  • len returns the actual number of items in the list, not the maximum index value.
  • 5
  • Yes, there are 5 items in this list.
You have attempted of activities on this page
Next Section - 10.4. Accessing Elements