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 Collections (2016, retired 2019) Dungeon Game Dungeon Entrance

What is the purpose of ("> ") in the while loop?

Confused on the purpose of this string.

3 Answers

I know this is waay late, but I believe you are referring to the following code:

while True:
    print("Welcome to the dungeon!")
    print("You're currently in room {}") # fill with player position
    print("You can move {}") # fill with available moves
    print("Enter QUIT to quit.")

    move = input("> ")
    move = move.upper()

    if move == 'QUIT':
        break

It helps to include the code but I'm pretty sure this is what concerned you, as I found it peculiar as well. The way the input() function works is, when written as input("insert text here"), the quoted text is printed as a prompt to get the desired input.

So, in the case of input("> "), the user will see:

and they are expected to plug in the desired input after that, followed by a return. This will record the input to the 'move' variable.

I hope that helps someone, at least.

Hmmm... it seems "> " is coded to be a quote... that makes it a little tricky to show, here. Pretty much, though, the user will see the greater-than symbol and will be prompted to type after that. Whatever they type after that is recorded into the variable 'move' as soon as they hit the 'Enter' key.

Shawn Denham
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree
Shawn Denham
Python Development Techdegree Student 17,802 Points

">" means greater than. so in a while loop is it usually used to evaluate a counter to keep you in the loop

ie.

Z = 10
while Z > 1:  #reads as while Z is greater than 1
    print(Z)
    Z = Z-1  #can also be written as Z -= 1

As long as Z greater than 1 it will print the value of Z

hope that helps!

-Shawn

its basic dude