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

I don't understand input and output code

I'm a beginning

Steven Parker
Steven Parker
243,318 Points

Please elaborate a bit more, and if appropriate include a link to the course page that is related to your question.

1 Answer

Steven Parker
Steven Parker
243,318 Points

The link is helpful, but it's not clear what your question is. But here's some generic hints:

When using input, you pass the message you want to show to the user as an argument inside parentheses. Then you can assign the function call to a variable that you want to hold the user's answer in. Here's an example:

answer = input("What is the answer? ")

Then to output a message, you can call the print function and pass the message you want to show as an argument in the same way. You can use concatenation to build a message by joining literal parts (in quotes) with variables using the "+" operator:

print("You said " + answer + " is the answer.")

Your code for the challenge will be similar, but you will follow the instructions for the actual messages and variable name.