Subsetting lists of lists
A Python list can also contain other lists.
To subset lists of lists, you can use the same technique as before: square brackets. This would look something like this for a list, house
:
house[2][0]
This exercise is part of the course
Introduction to Python
Exercise instructions
- Subset the
house
list to get the float9.5
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
house = [["hallway", 11.25],
["kitchen", 18.0],
["living room", 20.0],
["bedroom", 10.75],
["bathroom", 9.50]]
# Subset the house list
house___