Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getUserYN function to handle for wrong input values #24

Open
hari22yuva opened this issue Nov 6, 2024 · 0 comments
Open

Update getUserYN function to handle for wrong input values #24

hari22yuva opened this issue Nov 6, 2024 · 0 comments

Comments

@hari22yuva
Copy link
Contributor

def getUserYN(self, query="Please Enter Y or N :"):
"""
Reads Y/N user response to the query.

    Args:
    query (str, optional): Query to the user. Defaults to "".

    Returns:
    bool: returns the response. True for 'y'/'Y', False for 'n'/'N'.
    """
    if self.log is not None:
        self.log.debug(query)

    while True:
        response = input(query).strip().lower()  # Converts input to lowercase for simplicity
        if response == 'y' or response == 'Y' :
            return True
        elif response == 'N' or response == 'n':
            return False
        else:
            print("Invalid input. Please enter 'y' for Yes or 'n' for No.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant