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

Karma Lama
Karma Lama
849 Points

list creation... what am i missing here?

colors = [red, green, yellow, brown , black]

lists.py
colors = [red, green, yellow, brown , black]

2 Answers

Nicholas Grenwalt
Nicholas Grenwalt
46,626 Points

In Python words are represented as strings so they must be wrapped in single (') or double (") quotes. So for each of the colors in your list, make sure that they are surrounded with quotes so that they will be correctly read as strings within your list, i.e. 'red' or "red". Either way works.

Karma Lama
Karma Lama
849 Points

Thanks for the explanation... I tried doing

colors = ["red, green , yellow, brown, black"]

now I know, I need to put quotes in every single color... thanks again!

Manish Giri
Manish Giri
16,266 Points

It's generally a good habit to try and spend some time debugging your code, in case of errors. If there are any error messages shown, that's a good starting point.

If I run your code, I get this error - NameError: name 'red' is not defined. This should tell you what's wrong, red should be a string, with quotes -"red". Same goes for the remaining colors.

Karma Lama
Karma Lama
849 Points

Thanks.....again!