Learn

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"]

We can even combine multiple data types in one list. For example, this list contains both a string and an integer:

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!

Instructions

1.

Add any additional string to the end of the list ints_and_strings.

2.

Create a new list called sam_height_and_testscore that contains:

  1. The string "Sam" (to represent sam’s name)
  2. The number 67 (to represent sam’s average grade)
  3. The float 85.5 (to represent sam’s score)
  4. The boolean True (to represent sam passing the test)

Make sure to write the elements in exact order.

Sign up to start coding

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?