self_taught icon indicating copy to clipboard operation
self_taught copied to clipboard

Chapter 5, page 72 (paperback)

Open ON227 opened this issue 6 years ago • 1 comments

When I try using this code from the book:

colors = ["purple", "orange", "green"] guess = input("Guess a color:") if guess in colors: print("You guessed correctly!") else: print("Wrong! Try again.")

I then run the code and try guessing white to see my message for when it is wrong (although this is also happening when I guess a color that is in the list) I get the following error message:

Traceback (most recent call last): File "", line 2, in File "", line 1, in NameError: name 'white' is not defined

Am I doing something wrong? I typed it in just as it is written in the book.

ON227 avatar Jan 02 '19 18:01 ON227

Hey there,

Please post this in the Facebook group https://www.facebook.com/groups/selftaughtprogrammers/.

On Wed, Jan 2, 2019 at 10:01 AM ON227 [email protected] wrote:

When I try using this code from the book:

colors = ["purple", "orange", "green"] guess = input("Guess a color:") if guess in colors: print("You guessed correctly!") else: print("Wrong! Try again.")

I then run the code and try guessing white to see my message for when it is wrong (although this is also happening when I guess a color that is in the list) I get the following error message:

Traceback (most recent call last): File "", line 2, in File "", line 1, in NameError: name 'white' is not defined

Am I doing something wrong? I typed it in just as it is written in the book.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/calthoff/self_taught/issues/22, or mute the thread https://github.com/notifications/unsubscribe-auth/AID8zwseNcFtuZZZAEAiC3btYlY5uhNHks5u_PQBgaJpZM4ZnAa_ .

-- Cory Althoff www.goselftaught.com http://www.goselftaught.com

calthoff avatar Jan 02 '19 18:01 calthoff