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

"favorite color"

not sure if im using "print" for this one?

using_input.py
favorite_color=input("What is your favorite color?")
print("The color blue is my favorite!")

2 Answers

Kamaren McCord
Kamaren McCord
11,236 Points

Alright, so you almost have it here. It looks like you are manually entering the color "blue" into the print statement. The problem with that is that if the user puts in literally ANYTHING else, than 'blue', it will not be accurate. So what you need to do is use a string format to put the variable into the print statement

example:

variable_one = 'this is the insert'
print('this is my string, {}'.format(variable_one))

where the output will look like:

this is my string, this is the insert

Also, if you are using python 3.6 or higher, you can make use of "f string" which is very convenient.

    variable_one = 'this is the insert'
    print(f'this is my string, {variable_one}')

you can learn more about it here https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep498