Here is my code:
for count in range(1,numGames+1):
print()
try:
print("Game", str(count))
atBats = input("How many at bats did the player have? ")
atBats = int(atBats)
hits = input("How many hits did the player have? ")
hits = int(hits)
battingAverage = (hits / atBats)
except Exception as err:
print("Please enter a number")
print(err)
Currently, when a letter is entered for hitsor atBatsfor game 1, it throws an exception and says Please enter a number,, but it goes directly to Game 2, preventing the user from entering a new input for Game 1.
I would like to know if there is a way by which it resets the game score when an exception is thrown.
source
share