Python Python Basics (2015) Python Data Types List Creation

jamie Macdiarmid
jamie Macdiarmid
2,048 Points

Can someone remind show me?

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

lists.py
my_list= [red, yellow, green, blue, orange]

4 Answers

Grigorij Schleifer
Grigorij Schleifer
10,348 Points

Hi jamie,

try this:

colors = ["Red", "Yellow", "Blue", "Green", "Purple"]

Grigorij

jamie Macdiarmid
jamie Macdiarmid
2,048 Points

Hi. Thanks Grigorij. Forgot to put each color in "". Is that because I have to define each color?

Grigorij Schleifer
Grigorij Schleifer
10,348 Points

Hey,

you need " " for every word, so it can be recognised as a string. And the colors will represented as Strings here, so you are right

jamie Macdiarmid
jamie Macdiarmid
2,048 Points

Thanks again. sometimes you feel like eating your own neck!!

Grigorij Schleifer
Grigorij Schleifer
10,348 Points

I think this is something you need to hammer all this crazy programming stuff into your brain :)

Keep on hammering Pythonista !

The video does not show needing the " for each word.

Matthew Goldenberg
Matthew Goldenberg
3,096 Points

This is over a year late, but hopefully helpful to somebody. I believe (and could be mistaken) that "" is only necessary for anything that is NOT an integer. The lists in the video were all integers [1, 2, 3, 4, 5].

Can somebody confirm or reject this?