Learn
Creating and Modifying a List in Python
Lists II
Lists can contain more than just numbers.
Let’s revisit our height example:
- Jenny is 61 inches tall
- Alexus is 70 inches tall
- Sam is 67 inches tall
- Grace is 64 inches tall
We can make a list of strings that contain the students’ names:
names = ['Jenny', 'Alexus', 'Sam', 'Grace']
We can also combine multiple data types in one list. For example, this list contains both a string and an integer:
mixed_list = ['Jenny', 61]
Instructions
1.
Add any string to the list ints_and_strings
.
2.
Create a new list called sam_height
that contains:
- The string
'Sam'
- The number
67