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

Shouldn't the input to the variable favorite_color have space on both sides?

After my code, I get this error

AssertionError: Regex matched: 'Mauve ' matches 'Mauve\s{2,}' in 'The color Mauve is a great color!' : Close, but it seems you have an extra space between the color and the word 'is'

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

I believe the output would fetch spaces on both sides of the variable favorite_color.

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

1 Answer

The issue is that there are too many spaces. When you give print multiple arguments, it automatically adds spaces. There are two ways to fix this. One way is to omit the extra spaces:

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

Another way is to use concatenation (adding strings):

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

(Concatenation does not manually add spaces)

I hope this helps! :grin: :zap: ~Alex