Python Python Basics Meet Python Using Input

Use the favorite_color variable with your print statement to output the following message to the screen :

help!

using_input.py
favorite_color = input('what is your favorite color?')
print('the color, favorite_color, is a great color!')

2 Answers

adam n
adam n
57,282 Points

Your print statements comes out as:

the color, favorite_color, is a great color!

This is because your print statement is just one long string. It should be made up of strings and variables.

Let me know if this helps here

Christopher Thompson
Christopher Thompson
1,406 Points

Remember you can pass a comma separated list of values into the print function and it will print them out in the order that you specify them. The easiest way that Craig showed us how to do this for your question is to pass the three values into print like this (string, variable, string):

print ('the color ', favorite_color, ' is a great color!')

The more complex way he showed us is to use the string format method like this to insert the value of favorite_color into the middle of the string where the curly braces are, probably overkill for this task but may be helpful as you think more about strings and variables.

print ('the color {} is a great color!'.format (favorite_color))