Search code examples
exitshutdown

Exit shutdown function python


I've written the following code and if the else statement is true I would like the program to shutdown. I'm new to python and having some trouble

password = raw_input('Enter yes to continue:')
if password == 'yes':
    print'You have chosen to continue' 
else:
    print'You have chosen to exit'

Solution

  • Add this to your code

    import sys # This goes at the header
    ...
    if password == 'yes'
        pass # Your code goes on... I put the 'pass' just as a place holder
    else
        sys.exit()