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

needed help

using_input.py
favorite_color = input("what is your favorite color")
favorite_color = ("purple")
print("the color purple is great color"  )
Filipe Martins
Filipe Martins
2,824 Points
favorite_color = input("what is your favorite color")
print("the color {} is great color".format(favorite_color))

2 Answers

There is no need for you to input what the user is going to input. you are writing the code, so there is no need for you to define purple. You are writing the code so like this.

As Filipe Martins did!

favorite_color = input("What is your favorite color") print("The color {} is great color".format(favorite_color))

favorite_color = input("What is your favorite color") This code gets the color input from the user.

print("The color {} is great color".format(favorite_color)) This code prints the users color input and the string to the screen.

I hope this helped! Happy coding

P.S One other way to write the print statement would be like this. print("The color" ,favorite_color, "is great color") whichever one you want. :)

Steven Parker
Steven Parker
231,268 Points

Here's a couple of hints:

  • you should only assign "favorite_color" once (using "input")
  • you should combine the "favorite_color" answer with the output line

You can do the latter several ways, including string formatting as in the example Filipe offered, giving multiple arguments to the "print", or by building a longer single string with concatenation.