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

How do i do the sys exit program

Pls help me find out what's wrong

firedoor.py
import sys   
def start_movie():
    movie = input("Want to watch the show. Y/n").lower
    if movie != "n":
        return("Enjoy the show!")
    else:
        sys.exit()

2 Answers

Hey Nitin,

couple of things here. First, instead of returning the result, the task wants you to print it. And also, you don't need to use a function in this task. But if you do, remember to call it or your code won't do much. Here is how I solved it not using a functino:

import sys   

movie = input("Want to watch the show. Y/n").lower()
if movie != "n":
    print("Enjoy the show!")
else:
    sys.exit()

Here is a solution using a function:

import sys   

def start_movie():    
    movie = input("Want to watch the show. Y/n").lower()
    if movie != "n":
        print("Enjoy the show!")
    else:
        sys.exit()

start_movie()

You would still need to call the start_movie function at the end:

import sys   

def start_movie():    
    movie = input("Want to watch the show. Y/n").lower()
    if movie != "n":
        print("Enjoy the show!")
    else:
        sys.exit()

start_movie()

Thx