We’ve seen that the items in a list can be numbers or strings. They can also be other lists!
Once more, let’s return to our class height example:
- Jenny is 61 inches tall
- Alexus is 70 inches tall
- Sam is 67 inches tall
- Grace is 64 inches tall
Previously, we saw that we could create a list representing both Jenny’s name and height:
jenny = ['Jenny', 61]
We can put several of these lists into one list, such that each entry in the list represents a student and their height:
heights = [['Jenny', 61], ['Alexus', 70], ['Sam', 67], ['Grace', 64]]
A new student named
'Vik' has joined our class. Vik is
68 inches tall. Add a sublist to
heights that represents Vik and his height.
Create a list of lists called
ages where each sublist contains a student’s name and their age. Use the following data: