Lists can contain more than just numbers.
Let’s revisit our classroom example with heights:
- Noelle is 61 inches tall
- Ava is 70 inches tall
- Sam is 67 inches tall
- Mia is 64 inches tall
Instead of storing each student’s height, we can make a list that contains their names:
names = ["Noelle", "Ava", "Sam", "Mia"]
mixed_list_string_number = ["Noelle", 61]
Lists can contain any data type in Python! For example, this list contains a string, integer, boolean, and float.
mixed_list_common = ["Mia", 27, False, 0.5]
Let’s experiment with different data types in our own lists!
Add any additional string to the end of the list
Create a new list called
sam_height_and_testscore that contains:
- The string
"Sam"(to represent Sam’s name)
- The number
67(to represent Sam’s height)
- The float
85.5(to represent Sam’s score)
- The boolean
True(to represent Sam passing the test)
Make sure to write the elements in exact order.