Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Tuple basics
9. The len() function
Tuples in functions


Well done! To check the number of elements in a tuple, we can use the len() function:

user_data = ('John', 'Smith', 29, 1.85, 'British')
if len(user_data) > 4:
  print('A lot of info available!')

In the code above, we print 'A lot of info available!' only if there are more than four items in the user_data tuple.


Some tuples in the updated train_connections list don't have complete information about a given train connection. For each train connection with missing information, print the following line:

Missing train information for tuple: {tuple}

Stuck? Here's a hint!

We need four elements in each tuple, so check the following condition:

if len(item) < 4: