Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Shopping List App Shopping List Introduction

Paul Resendez
Paul Resendez
2,990 Points

Shopping List Introduction

At 4:30ish in the Shopping List Introduction video I am unclear as to what Kenneth is doing. He talks about using a simple prompt and uses a single '> ' symbol. Could someone help me out by elaborating on this? What exactly is he doing? Please help!

r h
r h
68,547 Points

What you are doing is actually creating a prompt yourself. Back in the day, when you coded in BASIC, whenever a prompt was needed from the user a ">" appeared on screen to the left of the cursor, which indicated that an input was required. This is a reference to BASIC stylization, because he wants us to input("> ") with the text that appears on screen just the "> " prompt. It's not even code, it's just a string. In other words, it could be input("Insert something to buy: ") and the cursor would wait to the right of the colon (:). > is just an abbreviation for input visually on the screen, not a python command or anything.

Paul Resendez
Paul Resendez
2,990 Points

Great! I understand. Thanks!

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,986 Points

The prompt can be any text string. The use of "*> *" is an arbitrary example. Whatever string is used as the argument to the input() function will be displayed to the user. Sometimes a specific question can be used as a prompt:

input("What do you need? ")

Yields

What do you need?

The cursor is left at the end of the prompt. A space is often left at the end if the prompt string to leave a visual gap between the prompt and the users input.

More info in Python docs input()

Paul Resendez
Paul Resendez
2,990 Points

Great! I understand. Thanks!