Created
September 27, 2021 03:14
-
-
Save cristian-aldea/d0f5d5c074a200b6d1606f4c94b9e3e8 to your computer and use it in GitHub Desktop.
Python: Confirmation function
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() -> bool: | |
""" | |
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 = input("Continue? [y/n]? ").lower() | |
return answer == "y" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment