Python Python Basics Meet Python Using Input

Anthony Carson
Anthony Carson
138 Points

where do I see the inputs from the user?

using_input.py
favorite_color = "Red"
input("What is your favorite color?")
print("The color", "favorite_color", "is a great color!")

3 Answers

joelearner
joelearner
36,591 Points

Hi Anthony,

It looks like you're having trouble with part 2 of the challenge?

In part 2, the teacher writes:

For instance, if I enter "purple" I want your code to print:

The color purple is a great color!

This means that the hard coded "Red" isn't going to work and you have to find a way to make it so that if the teacher types in any color, he will get back the color he wants inserted into the sentence above.

So looking at the code you have...:

favorite_color = "Red"
input("What is your favorite color?")
print("The color", "favorite_color", "is a great color!")

...let's drop the "Red" part leaving you with:

favorite_color =
input("What is your favorite color?")
print("The color", "favorite_color", "is a great color!")

Here, you can simply bring the input statement you already have up to the same line that the favorite_color variable is defined, like this:

favorite_color = input("What is your favorite color?")
print("The color", "favorite_color", "is a great color!")

Also, you will need to remove the quotes from favorite_color in the print statement. For some reason, you will be able to pass task 1 just fine but task 2 requires that you enter the variable name as a variable and not a string. Your finished code should look something like this:

favorite_color = input("What is your favorite color? ")
print("The color", favorite_color, "is a great color!")

Cheers!

I don't get the second part