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

Jack Cummins
Jack Cummins
17,417 Points

Need help with code challenge. Why am I wrong?

Use the favorite_color variable with your print statement to output the following message to the screen :

The color [USER INPUTTED COLOR] is a great color!

What code would pass this scienario? Jack

Thanks!

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

2 Answers

Brandon Spangler
Brandon Spangler
8,756 Points

print("The color "+favorite_color+ " is a great color") Also, Rimvydas Česonis code does pass.

Rimvydas Česonis
Rimvydas Česonis
8,170 Points

Hello,

print("The color ", favorite_color, " is a great color") # you left extra space on both of your strings one after and one in front of it. You need only one, first one.

Updated: for Task 1

favorite_color = input("What is your favorite color? ")

for Task 2

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

I did not post you correct answer at first, because I wanted you to find it yourself, but here it is. I checked it myself and it works.

Jack Cummins
Jack Cummins
17,417 Points

That code does not pass. :angry:

Craig Dennis
Craig Dennis
Treehouse Teacher

The extra space in "The color " is not needed. print with multiple arguments will join all values separated by spaces.

Jack Cummins
Jack Cummins
17,417 Points

Thanks Craig! You are the best! You are my favorite teacher on treehouse. I love your teaching style!