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 trialKyle Weidner
110 PointsI'm confused by the second part of this last input question? What should the code say?
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!' )
1 Answer
frankgenova
Python Web Development Techdegree Student 15,616 PointsThere 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!")
Reggie Williams
Treehouse TeacherReggie Williams
Treehouse TeacherHey 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")