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 trialsamuel octelene
1,014 Pointsinput and coding style challenge? i am not sure where i went wrong.
/
favorite_color = input("What is your favorite color? ")
favorite_color = "red"
print("The color", "favorite color", "is a great color!")
1 Answer
Viraj Deshaval
4,874 PointsLet me tell you first how your code is behaving.
You are asking for your favorite color and storing in favourite_color
and then you are overriding the favourite_color
value by passing 'red'.
Lastly you are simply printing the strings with no reference to variable.
In order to display variable values you need to add variable name without quotation mark in 'print()' statement.
Let me clear your doubts step by step:
Step - 1: Create a variable and ask for your favorite color using input()
.
Note: input()
always returns string.
favourite_color = input("What's your favourite color? )
Step - 2: print the favourite color using print statement.
print("The color ", favourite_color, " is a great color")