"Introduction to HTML and CSS (2016)" was retired on July 31, 2024. You are now viewing the recommended replacement.

Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Meet Python Using Input

Omar Salim
Omar Salim
150 Points

Why is this wrong?

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

3 Answers

Rick Gleitz
Rick Gleitz
47,877 Points

Hi Omar,

Just a few problems here.

Your second line is not needed. It redefines the variable favorite_color to mean only Blue. You want whatever color the input is to be printed in the statement, not just Blue.

To do that, in the third line replace the word Blue with the variable name, which now contains whatever color was put in, so it will show up in the statement.

Lastly, take out the space before the word 'is' in your print statement. It's not needed and will cause the Treehouse's checking system to throw an error.

(Technically, the statement in the first line should not begin with a space either, and the 'what' should be 'What', but neither of these threw an error. On some challenges such things might do so. It's best to always match what the instructions say exactly).

I hope this helps!

Omar Salim
Omar Salim
150 Points

Thank you so much. I appreciate your help.

Omar Salim
Omar Salim
150 Points

Thanks . I really appreciate your help.

Alan Luo
Alan Luo
223 Points

I was confused at the beginning of this question, so I youtube python found different ways to achieve this. favorite_color = input("What is your favorite color\n")

print(f"The color {favorite_color} is a great color!")