0

条件付きステートメントを含むコードをいくつか書いたことがありますが、それが起こることになっているとは思いません。

何度もコードを書き直そうとしました。

def main():
def enter():
  inputenter = input("Please enter a number. ")
  if inputenter in ("1", "2", "3", "4", "5"):
    getready()
  else:
    inputstartagain = input("Invalid Request") 
def getready():
  inputgetreadybrush = input("Did you brush your teeth? ")
  if inputgetreadybrush == "Yes" or "yes" or "y" or "Y":
    inputgetreadyshower = input("Did you shower? ")
    if inputgetreadyshower == "Yes" or "yes" or "y" or "Y":
      print("Your output is: I already got ready. ")
    elif inputgetreadyshower == "No" or "no" or "N" or "n":
      print("Your output is: Shower ")
    else:
      print("")
  elif inputgetreadybrush == "No" or "no" or "n" or "N":
    inputgetreadyshower1 = input("Did you shower? ")
    if inputgetreadyshower1 == "Yes" or "yes" or "Y" or "y":
      print("Your output is: Brush ")
    elif inputgetreadyshower1 == "No" or "no" or "n" or "N":
      print("Your output is: Brush and Shower ")
  else:
    print("")

main()

(これらは if ステートメントへの回答です) 1,y,n の出力は "Your output is: Shower" であると予想していましたが、実際の出力は "Your output is: I already got ready." です。

4

3 に答える 3

0

すべての条件を正しい構文に変更します。

if (inputgetreadybrush == "Yes") or (inputgetreadybrush == "yes") or (inputgetreadybrush == "y") or (inputgetreadybrush == "Y"):

これですべての問題が解決します。

于 2019-08-07T01:48:57.147 に答える