Please help

Joined
Jun 27, 2022
Messages
6
Reaction score
1
So I am on a phone while coding(don't ask why) but I was coding and this is what I wrote on the problem lines:


if(guess1 == blue):
print("Wow! You must be a mind reader!")

I can run the program, but when it gets to the conditional line, it says that 'blue' is not defined. I don't know what to do. Please help!
 
Joined
May 11, 2022
Messages
61
Reaction score
6
so colors aren't coded in. you have to put in the hex value. #0000FF.
I've never really messed wit colors so I'm not sure how accurate that is.
 
Joined
Jun 24, 2022
Messages
4
Reaction score
0
Hey, Codergirl2010! Are you trying to check if the user typed the word 'blue' or if the user typed the actual HEX color code?

1. Checking if the user typed 'blue':

Python:
if (guess == "blue"):
    print("Wow! You must be a mind reader!")

2. Checking if the user typed the actual HEX color code (see @phillip1882's answer):

Python:
if (guess == "#0000FF"):
    print("Wow! You must be a mind reader!")

Explanation: the 'NameNotFound exception' is raised when we try to use a variable or a function name that is not valid. In your case, Python was searching for a variable named 'blue'. As it didn't find it, it raised that exception.

HTH,
MrSevyu
 
Last edited:
Joined
Jun 27, 2022
Messages
6
Reaction score
1
So this is the whole thing
 

Attachments

  • 20220627_073717.jpg
    20220627_073717.jpg
    50.5 KB · Views: 9

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top