Created
May 4, 2016 13:43
-
-
Save gurunars/4470c97c916e7b3c4731469c69671d06 to your computer and use it in GitHub Desktop.
Ask for confirmation in Python
This file contains 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
def confirm(): | |
""" | |
Ask user to enter Y or N (case-insensitive). | |
:return: True if the answer is Y. | |
:rtype: bool | |
""" | |
answer = "" | |
while answer not in ["y", "n"]: | |
answer = raw_input("OK to push to continue [Y/N]? ").lower() | |
return answer == "y" |
It still perfectly works. Thank you !!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For python3 use input()