Python Python Basics Meet Python Using Input

Skylar Claypool
Skylar Claypool
507 Points

Favorite_Color Input question

Anyone else get this error when you put in "Purple" but it reads it as "Red"?

using_input.py
favorite_color = input("What is your favorite color?")
favorite_color = 'purple'
print("The color",favorite_color,"is a great color!")
Skylar Claypool
Skylar Claypool
507 Points

FAIL: test_input_called (main.TestUsingInputExecution)

Traceback (most recent call last): File "/usr/local/lib/python3.6/unittest/mock.py", line 1179, in patched return func(*args, **keywargs) File "", line 32, in test_input_called AssertionError: 'Red' != 'purple'

  • Red
  • purple : Hmm...I answered the prompt with 'Red' but that's not what was in the variable favorite_color

-I did put 'purple' but it is reading it as 'red' and Im not sure why.

2 Answers

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi! The challenge is asking you to ask the user for their favorite color and then print it out with the sentence 'The color [input] is a great color!'. The color purple is just an example of what a user's input might be. Your code should be able to take any color input and print it out. Right now you are taking their input and then overwriting it with 'purple' and printing out the message so the message will always be 'The color purple is a great color!'. Instead, the message should always use the input from the user so if they input 'red' as their favorite color, the message will print out 'The color red is a great color!' or 'green' -> 'The color green is a great color!'

Skylar Claypool
Skylar Claypool
507 Points

I was able to fix by removing favorite_color = 'purple'. Thank you!