GabrielZandie (0)

what code is it for yes or no question like if you are on a website and you see do you want to log in or sign up I would like the code for it.

You are viewing a single comment. View All
JustARatherRidi (190)

Here's how you can check whether the user wants to log in or not, and make the program continue accordingly:

response = input("Would you like to login? ").lower()

if response in ('y', 'yes'):
    username = input('Please enter your username: ')
    print(f'\nWelcome, {username}!')

elif response in ('n', 'no'):
    print('Okay, bye!')

    print('Invalid input, try again!')

(Working repl)

If you were looking for something else, please try to make your question a bit more specific.