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

mohan Abdul
PLUS
mohan Abdul
Courses Plus Student 1,453 Points

answering 1st prompt, the teacher put the question in the text editor and answers in console. i have no console in task.

so how do I answer the first prompt?

using_input.py
favorite_color = input("what is your favorite color?")
purple
print("the color", favorite_color, "is a great color!")
mohan Abdul
mohan Abdul
Courses Plus Student 1,453 Points

In the video the teacher inputs the prompt and variable in the text editor, and answers the prompt in the console. in this task i have no console, so how do I input the second line?

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,722 Points

You are correct in identifying that there are two different contexts under which you can execute the Python code. These contexts can be a Python script (run by the Python interpreter), or the Python REPL (this is just a fancy term for a Python interactive shell).

The challenge is simply asking you to input the Python script. You don't need to supply the input line "purple". The script below will pass the challenges.

favorite_color = input("what is your favorite color?")
print("the color", favorite_color, "is a great color!")

The automated grader of challenges supplies the input and unit tests.

Good luck with your Python journey, it is a great and useful language!

mohan Abdul
mohan Abdul
Courses Plus Student 1,453 Points

Jeff Muday, hi thank you replying I have done as you suggested, in the test results of the box which is on the right side where you check your work before hiting the box check my work. Well in that box its given me an output - 'the color red is a great color!'. why isn't the output purple. As step 2 states "I will respond with my favorite color when I run your script. For instance, if I enter "purple" I want your code to print:" "The color purple is a great color!".