0

I am trying to quit a python program with either "q" or "Q" but when I put in "Q" it give an error message about the syntax being incorrect.


   else:
            print("That was an invalid response. Enter a number or 'q' to quit.")
    # <<Check correctness of user's response>>
    if response == 'q''Q':
        keep_asking_questions = False

I tried replacing if response == 'q''Q': and if response == 'q,Q':

none worked.

k.rob
  • 53
  • 1
  • 1
  • 9
  • The first one asks if `response` is equal to the two characters `qQ`; the second if it is literally the three characters `q,Q`. To test if it is one of the following characters, `response in 'qQ'`; if you want one of the following strings, `response in ['q', 'Q']`. – Amadan Nov 14 '22 at 01:03
  • Nope, wrote if response == ['q', 'Q']: still say's it's a invalid response unless I put the end bracket in the wrong place maybe. – k.rob Nov 14 '22 at 01:31
  • What does if response.lower() do ? – k.rob Nov 14 '22 at 01:35

0 Answers0