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

I'm confused by the second part of this last input question? What should the code say?

using_input.py
favorite_color=input('purple')
input ('what is your favorite color?')
favorite_color= input ('what is your favorite color?')
print('the color (purple) is a great color!' )
Reggie Williams
Reggie Williams
Treehouse Teacher

Hey Kyle Weidner nice start. The code should use the variable you created to print out the value the user inputs. You can separate your string and variable values using commas like this :

print("first part of sentence", variable, "end of sentence")

1 Answer

There are a couple of ways to 'interpolate' a string variable.

favorite_color = input("What is your favorite color?")
# all of the following print statements are equivalent
# print("The color",favorite_color,"is a great color!")
# print("The color {} is a great color!".format(favorite_color))
print(f"The color {favorite_color} is a great color!")