1

I am trying to create a program; however, even when 'y' or 'yes' is entered, the code still goes to the 'n'/'no' loop. Any suggestions?

no = input("How many messages?")
intNo = int(no)
msgno = input("2 different msgs? [y/n]:")
message = input("Message:")
message2 = input("Message 2:")

run = True
pyautogui.click(x=980, y=805, button='left')
while run == True:
    if msgno.lower() == "n" or "no":
        pyautogui.typewrite(message, interval=0.00001)
        pyautogui.press('enter')
        intNo = intNo - 1
        if intNo <= 0:
            run = False
    elif msgno.lower() == "y" or "yes":
        no = no / 2
        pyautogui.typewrite(message, interval=0.00001)
        pyautogui.press('enter')
        pyautogui.typewrite(message2, interval=0.00001)
        pyautogui.press('enter')
        intNo = intNo - 1
        if intNo <= 0:
            run = False

1 Answers1

2

You have to add two conditional statements to each If statement. Like this: if msgo.lower() == 'yes' or msgo.lower() == 'y' If you have just a variable that exists or a value, it will default to True, so where "no" was defaulted to True and went into the code-block.

Pike D.
  • 671
  • 2
  • 11
  • 30