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) Letter Game App Exiting

Use input() to ask the user if they want to start the movie. If they answer anything other than "n" or "N" print "Enjoy

answer = input("Do you want to start the movie")
if answer = "n" or "N"
   print("Enjoy the show!")
else:
   sys.exit()

help please!

3 Answers

Kevin Faust
Kevin Faust
15,353 Points
  1. you need to import the sys library

  2. You forgot a semicolon (:) at the end of your if statement

  3. You had to use double equals (==) instead of a single one in your if statement because we are comparing

  4. do answer.lower() != "n" isntead of what you got. otherwise you have to do this:

 answer != "n" or answer != "N"

thanks

Isaac Al-Wahaibi
Isaac Al-Wahaibi
6,403 Points

add import sys , so you can use sys.exit(), also in if statement you have something wrong , if they type "n" it will show "Enjoy the show"

hope this helps

import sys

answer = input("Do you want to start the movie?")

if answer.lower() != "n":
    print("Enjoy the show")
else:
    sys.exit()

thank you !

Kutay Yavuz
Kutay Yavuz
1,387 Points

import sys a = input("Wanna watch a movie?? y/n") if a !="n": print("Enjoy the show!") else: sys.exit()

if a !="N": print("Enjoy the show!") else: sys.exit()

its working