# asks the question and gives the choices
choice=input('what is your favourite colour? press 1 for red, 2 for blue, 3 for yellow or 4 to quit')
# if the responder responds with choice 1 or 2,3,4 it will print this
if choice=='1' or 'one':
print('red means anger')
elif choice=='2'or 'two':
print('blue represents calmness')
elif choice=='3' or 'three':
print('yellow represents happiness')
elif choice=='4' or 'four':
print('it was nice meeting you. goodbye.')
else:
print('sorry incorrect answer please try again.')
我的一個學生寫了這個,我似乎無法得到它的工作。 幫助!它不斷重複紅色意味着憤怒。如果我註釋掉'或', 它有效,但爲什麼她不能使用'或'?我希望她添加一個循環,但只有 ,如果這項工作第一。IF語句被忽視或不接受的邏輯運算符「或」
你或語句被解讀爲此爲(選擇== 1)或'one'),評估'one'永遠是對的 – Skycc
這是哪一種語言? Visual Basic.net? – Dronz