Created
April 17, 2017 16:14
-
-
Save christoga/e6175ac6df16ee2ae51fe25da7f83dd2 to your computer and use it in GitHub Desktop.
Python exit snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import time | |
| def main(): | |
| exit() | |
| def exit(): | |
| input = raw_input("Exit? Yes[y] or No[n] ") | |
| if input == 'y': | |
| print 'Exiting program...' | |
| time.sleep(2) | |
| elif input == 'n': | |
| main() | |
| elif input == 'yes': | |
| print 'Your answer isn\'t right \nBut it\'s okay.' | |
| time.sleep(2) | |
| elif input == 'no': | |
| main() | |
| else: | |
| print 'Please answer the question' | |
| exit() | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment