'highscore and keeping score
#This is a for loop to get the score of a player playing a riddle game #It runs and loops but it's not calculating the score properly. #There're 6 riddles and 3 rounds. #Say I get 4/6 correct my score is 20 but it's displaying 3.0 instead. how do I get a precise answer while importing the math function?
for i in range(6):
print(riddles[i])
#
userchoice = input("Enter A, B, C, or D: ")
if userchoice.upper() == answers[i]:
print("That's Correct")
score += 5
print(f" {score}")
else:
print("That's Incorrect")
score -= 1
print(f"{score}")
total = total + int(score)
highScoreEasy = print(f"Here is your score: {int(total/score)} !!!!!")
print()
Solution 1:[1]
Shouldn't it just be a simple sum?
riddles = []
answers = []
riddle_score = 5
total = len(riddles) * riddle_score
score = 0
for i, riddle in enumerate(riddles):
print(riddle)
userchoice = input("Enter A, B, C, or D: ")
if userchoice.upper() == answers[i]:
print("That's Correct")
score += riddle_score
else:
print("That's Incorrect")
print(f"Here is your score: {score}/{total}!")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kriss |
