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 Exiting

Andrew Morgan
Andrew Morgan
577 Points

Didn't get an exit from 'start_movie'

I'm not sure why this isn't getting an exit on the firedoor.py challenge. I originally tried this:

import sys

start_movie = input("Would you like to start the movie? Y/N: ").lower()
if start_movie.lower() != 'n':
    print("Enjoy the show!")
else:
    sys.exit

Which failed.

In the end, I solved by adding parentheses after sys.exit, like so:

import sys

start_movie = input("Would you like to start the movie? Y/N: ").lower()
if start_movie.lower() != 'n':
    print("Enjoy the show!")
else:
    sys.exit()

But in the hangman exercise we just completed before this, Kenneth had used the following:

def welcome():
    start = input("Press ENTER to start or Q to quit: ").lower()
    if start == 'q':
        print("Bye!")
        sys.exit
    else:
        return True

Why is his use of 'sys.exit' working without the parentheses and mine wasn't? Not sure I'm 100% grasping that concept.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Not sure where you are seeing Kenneth use sys.exit() without parens. In the video Letter Game Refinement he uses parens at 9:05 and 10:50

Where are you seeing the use without parens?