Get Started

Create lists with different types

Although it's not really common, a list can also contain a mix of Python types including strings, floats, and booleans.

You're now going to add the room names to your list, so you can easily see both the room name and size together.

Some of the code has been provided for you to get you started. Pay attention here! "bathroom" is a string, while bath is a variable that represents the float 9.50 you specified earlier.

This is a part of the course

“Introduction to Python”

View Course

Exercise instructions

  • Finish the code that creates the areas list. Build the list so that the list first contains the name of each room as a string and then its area. In other words, add the strings "hallway", "kitchen" and "bedroom" at the appropriate locations.
  • Print areas again; is the printout more informative this time?

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

hall = 11.25
kit = 18.0
liv = 20.0
bed = 10.75
bath = 9.50

# Adapt list areas
areas = [____, hall, ____, kit, "living room", liv, ____, bed, "bathroom", bath]

# Print areas
____

This exercise is part of the course

Introduction to Python

BeginnerSkill Level
4.8+
2342 reviews

Master the basics of data analysis with Python in just four hours. This online course will introduce the Python interface and explore popular packages.

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free