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 don't know this task I tried it and watched the video but its really hard to understand, Thanks for reading

using_input.py
favorite_color = input('What Is Your Favorite Color?')
print("favorite_color")
print("My favorite color is blue")

3 Answers

Here is one way to solve it for basic level.

#favorite_color = input('What Is Your Favorite Color?') 
favorite_color = input('What is your favorite color? ')  #--> remember space at the end <--
#print("favorite_color")
print('The color ' + favorite_color + ' is a great color!') # --> remember space after '...color ' and before ' is a..' <--
Guillermo Gallo
seal-mask
.a{fill-rule:evenodd;}techdegree
Guillermo Gallo
Full Stack JavaScript Techdegree Student 8,518 Points

Hi arix business ,

Your code so far looks good, but needs a few adjustments.

So in general this task is about asking the user what their favorite color is and then printing on the screen the color they entered together with the text "The color [color] is a great color!".

First, make sure you are doing exactly what the task is asking. The first task tells you exactly what you should ask in your input "What is your favorite color? ". You must copy/write it exactly as the question says, with the same letter case and spacing (notice the extra space at the end of the question), otherwise it wont pass the check.

On the second step of this task you need to print the user input, which you saved in the first step to the variable favorite_color. Right now what you are printing is just a string with the word favorite_color in it, so you are not displaying the actual variable value. To print the actual variable value you need to place the variable name without quotes inside your print statement, but the print statement should also include the rest of the text that needs to be printed. You should only have one print statement that combines the text that needs to be printed with the value stored in the favorite_color variable.

Make sure to go over your notes or the course video to review how to include the variable value in the print statement together with the rest of the string.

Hope this helps

Asher Orr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Asher Orr
Python Development Techdegree Graduate 9,408 Points

Hi Arix Business!

The challenge asks you to ask for a user's input, then store it in a variable. You did that perfectly with this line of code:

favorite_color = input('What Is Your favorite color?')

When someone runs a Python script with that line of code, they will see "What is your favorite color?" printed to the screen. They'll type their answer and press enter. Python will remember their answer. Specifically, it will store it in the variable favorite_color.

Check out the next line of code:

favorite_color = input('What is your favorite color?')
print(favorite_color)

Now, Python will print whatever is stored in the variable favorite_color.

The second step in the challenge is asking you to write a print statement that prints out "The color [their color] is a great color!" to the screen.

Currently, your code is doing this:

favorite_color = input('What is your favorite color?')
# ask user for their favorite_color
print(favorite_color)
# print whatever they enter
print("My favorite color is blue")
# print "my favorite color is blue"

It should look like this:

favorite_color = input('What is your favorite color?')
# ask user for their favorite_color
print("The color [their_color] is a great color!")

You may be thinking "but how do I get my user's response, which was stored in favorite_color, in the print statement?" To answer that, check this out: https://realpython.com/python-string-formatting/#2-new-style-string-formatting-strformat

I hope this helps!