I'm working on a mini-project for my intro to python course. We've been assigned to build a "guess the door that's hiding the car" simulator where the program makes the guess for you and tells you how many times the player guessed the right door at the very end. I'm not sure how to get the end number of wins to print at the end of the program, here's the main section of code I'm talking about:
for turn in range(1, rounds + 1):
wins = 0 # Accumulator for number of wins.
car = randint(1, 3)
choice = randint(1, 3)
if decision == "switch":
print("Round:", turn)
print("Player's guess was Door #", choice, sep='')
choice = randint(1, 3)
print("Player switched to Door #", choice, sep='')
if choice != car:
wins = wins + 0
elif choice == car:
wins = wins + 1
elif decision == "stay":
print("Round:", turn)
print("Player's guess was Door #", choice, sep='')
if choice != car:
wins += 0
elif choice == car:
wins += 1
print("Player won ", wins, " rounds.")
Every time i run the program, the number of wins at the end of the rounds is 0. I'd like it to show the number of times that the choice == car, and apparently I'm not sure how to go about this... I would really appreciate any suggestions. Thanks!
Aucun commentaire:
Enregistrer un commentaire