Python Python Basics (2015) Python Data Types List Creation

Darren Taylor
Darren Taylor
1,038 Points

Hi, please help. I'm having problems making this list: My_list = colors + [blue, green, yellow, orange, red]

The question reads:

Make a new list variable named colors. Fill it with at least 5 items. They should be colors but I won't mark you off for that.

lists.py
My_list = colours + [blue, green, yellow, orange, red]

1 Answer

Hey!

You were going sort of in the right direction with your code, but there are a few things you need to correct:

  • Text is a string, not a number. When writing text, or strings, you need to put them in apostrophes: "blue"
  • You can't use "+" as a way of assigning a list to a variable, if you change the "+" to a "=", then My_list would be equal to the items in colours.
  • Lastly, the challenge asks for a variable named "colors". Not "My_list", or "colours".

Correct:

colors = ["blue", "green", "yellow", "orange", "red"]
Darren Taylor
Darren Taylor
1,038 Points

Thanks a lot for your help Magnus, your explanation has taught me something new and it does work now. Once again, thanks.

No problem! :)