Introduction to Python
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner
    **Python Lists ** How to create a list? **`As opposed to int, bool etc., a list is a compound data type; you can group values together:`*
    a = "is"
    b = "nice"
    my_list = ["my", "list", a, b]

    After measuring the height of your family, you decide to collect some information on the house you're living in. The areas of the different parts of your house are stored in separate variables for now, as shown in the script.

    Create list with different types A list can contain any Python type. Although it's not really common, a list can also contain a mix of Python types including strings, floats, booleans, etc.

    The printout of the previous exercise wasn't really satisfying. It's just a list of numbers representing the areas, but you can't tell which area corresponds to which part of your house.

    The code in the editor is the start of a solution. For some of the areas, the name of the corresponding room is already placed in front. Pay attention here! "bathroom" is a string, while bath is a variable that represents the float 9.50 you specified earlier.