Python Python Basics (2015) Letter Game App Exiting

siva sanka
siva sanka
4,099 Points

please help me regarding this

import sys movie= input('please enter any thing to start or N/n to to exit') if movie == 'n' or 'N': sys.exit() else: print("Enjoy the show!")

firedoor.py
import sys
movie= input('please enter any thing to start or N/n to to exit')
if movie == 'n' or 'N':
    sys.exit()
else:
    print("Enjoy the show!")

1 Answer

Farid Wilhelm Zimmermann
Farid Wilhelm Zimmermann
16,727 Points

I am not sure I understand what your issue is, but I think you wanted to call sys.exit() only if your input evaluates to 'n' or to 'N'. You have to declare it like this:

if movie == 'n' or movie == 'N':
    sys.exit()

The way you currently defined your condition, the interpreter will read it as follows

if movie == 'n' or 'N' == TRUE:
    sys.exit()

This will always evaluate to TRUE.

When you are using boolean operators and are comparing values, you have to make that comparison on both sides of the operator.