Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

Python Question of the Day Feb. 21, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    The following code asks a user to input a response. What string method can be used to ensure that the phrase “Invalid response” only displays if the user types something other than “yes” or “no”, without paying attention to the text’s capitalization?

    birthday = input("Is today your birthday? (yes/no): ")
    if birthday == "yes":
        print("Happy Birthday!")
    elif birthday == "no":
        print("Happy Unbirthday!")
    else:
        print("Invalid response")
    Python