1
我想創建一個程序;然而,即使輸入'y'或'yes',代碼仍會進入'n'/'no'循環。有什麼建議麼?'elif'''while''loop
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
'「y」或「是」==「y」',總是。在[「y」,「yes」]中嘗試'msgno.lower()。 – Maroun
'if msgno.lower()==「n」或msgno.lower()==「no」'或'如果msgno.lower()不在['n','no']'你不能通過兩個條件一起 – Arman