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 (2015) Letter Game App Letter Game Introduction

How does this code start the game?

I see how q quits the game, but I don't see any code related to enter or " " that would make the game start.

start = input("Press enter/return to start or q to quit: ")
    if start.lower() == "q":
        break

So then the input doesn't actually start the game...it stops it. Am I the only one that had to belabor that!? duh...

1 Answer

Clayton Perszyk
MOD
Clayton Perszyk
Treehouse Moderator 48,850 Points

In the video, Kenneth uses a while loop that is set to true; when the program runs the loop will run; it will keep running until you enter q. If you do enter q then the condition if start.lower() == "q": will evaluate to true and the break keyword in the conditional will exit the loop and the program will end.

Hi Clayton. I get that part, entering q triggers break and exits the program. But I don't see any code attached to "enter" to trigger the start of the game/loop

are you saying the loop will start by default as long as q is not entered? If so then why does it not start automatically?

  • I would expect to see something like
if start == "":
  something to make the loop start

Wait I think I get it, the input is stopping the loop because input has to finish cause it's the first part of the code.