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

T Ghosh
T Ghosh
3,293 Points

Why am i getting the 'Assertion Error' for the code ?

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

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

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Super close!

When you use the print statement with multiple arguments, it separates the values automatically with a space. The test is looking very specifically for:

The color red is my favorite color

While your code is outputting:

The color  red  is my favorite color

Note the extra spaces in the second one. Your strings before and after don't need the extra spaces.

Does that make sense?

(Those spaces will come in handy later when you use concatenation with a + sign.)

I'll add a test to make the error more clear.

T Ghosh
T Ghosh
3,293 Points

Thank you Craig! It works now :)

This is in python 3. But in python 2.7 we have to use + sign to concatenate 2 strings otherwise it will print as two separate list

in 2.7

print ("abc","xyz")

('abc', 'xyz')

print ("abc"+"xyz") abcxyz