Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python Data Types List Creation

Darren Taylor
Darren Taylor
1,052 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,052 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! :)