Wieso wird die eine if-Anweisung nicht ausggeführt?
Verfasst: Donnerstag 21. April 2022, 09:07
Hallo,
Ich muss für die Uni das Schere Stein Papier Spiel programmieren, jedoch werden bei meinem Code nach dem print Befehl: print(f"The computer has choosen {choice_computer} . ") nicht ausgeführt. Wieso ist das so??
Der Code:
def random_choice():
number = random.randint(1, 3)
choice = None
if number == 1:
choice = "SISSORS"
elif number == 2:
choice = "ROCK"
elif number == 3:
choice = "PAPER"
return choice
while True:
choice_computer = str(random_choice())
points_c = 0
points_p = 0
choice_player = str(input("Welcome to Rock Paper Sissors. Choose Rock, Paper or Sissors!"))
if choice_player.upper() == ("ROCK" or "SISSORS" or "PAPER"):
print(f"The computer has choosen {choice_computer} . ")
if (choice_player == choice_computer):
print("Es ist unentschieden")
elif(choice_player.upper == "ROCK" and choice_computer == "SISSORS") or (choice_player.upper == "SISSORS" and choice_computer == "PAPER") or (choice_player.upper == "PAPER" and choice_computer=="ROCK"):
points_p += 1
print("Der Spieler gewinnt")
elif (choice_computer == "ROCK" and choice_player.upper == "SISSORS") or (choice_computer == "SISSORS" and choice_player.upper == "PAPER") or (choice_computer == "PAPER" and choice_player.upper== "ROCK"):
points_c += 1
print("Der Computer gewinnt")
else:
print("There has been a mistake!")
print("Next round!!")
Ich muss für die Uni das Schere Stein Papier Spiel programmieren, jedoch werden bei meinem Code nach dem print Befehl: print(f"The computer has choosen {choice_computer} . ") nicht ausgeführt. Wieso ist das so??
Der Code:
def random_choice():
number = random.randint(1, 3)
choice = None
if number == 1:
choice = "SISSORS"
elif number == 2:
choice = "ROCK"
elif number == 3:
choice = "PAPER"
return choice
while True:
choice_computer = str(random_choice())
points_c = 0
points_p = 0
choice_player = str(input("Welcome to Rock Paper Sissors. Choose Rock, Paper or Sissors!"))
if choice_player.upper() == ("ROCK" or "SISSORS" or "PAPER"):
print(f"The computer has choosen {choice_computer} . ")
if (choice_player == choice_computer):
print("Es ist unentschieden")
elif(choice_player.upper == "ROCK" and choice_computer == "SISSORS") or (choice_player.upper == "SISSORS" and choice_computer == "PAPER") or (choice_player.upper == "PAPER" and choice_computer=="ROCK"):
points_p += 1
print("Der Spieler gewinnt")
elif (choice_computer == "ROCK" and choice_player.upper == "SISSORS") or (choice_computer == "SISSORS" and choice_player.upper == "PAPER") or (choice_computer == "PAPER" and choice_player.upper== "ROCK"):
points_c += 1
print("Der Computer gewinnt")
else:
print("There has been a mistake!")
print("Next round!!")