Python Python Basics Meet Python Using Input

Rafael Gutierrez
Rafael Gutierrez
146 Points

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,360 Points
favorite_color = input("what is your favorite color")
print("the color {} is great color".format(favorite_color))

2 Answers

Steven Parker
Steven Parker
180,223 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.

SILAS HOLT
SILAS HOLT
3,010 Points

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. :)