Я хочу создать внешний CSV-файл, который отслеживает высокий балл (например, если бы я набрал 10 баллов, он сделал бы сравнение, чтобы увидеть, превышает ли он текущий текущий балл, а затем, если это так, он перезапишет его вфайл csv)
Google
import random
import csv
name = input("enter your name: ")
timesplayed = 1
print("Welcome to the quiz ",name," Good Luck")
print("Rules:")
print("I will randomize two number in between 0 and 12")
print("after it has been randomized you will be shown both the randomized number")
print("you will have to multiply them together and enter the answer!")
theo = 0
score = 0
again = ("")
an = 0
gamesplayed = 0
print("the high score is" (highscore))
while theo >= 0 and theo <=9:
theo = theo + 1
x = (random.randint(0, 12))
y = (random.randint(0, 12))
print("Your sum is: " ,y,"x ",x)
answer = input("What is the answer?: ")
while len(answer) == 0:
answer = input("What is the answer?: ")
an = (x*y)
if int(answer) == (an):
print("Well done - you were correct ")
score = score + 1
elif int(answer) != (an):
print("Sorry, you were wrong. The correct answer was " ,an)
if theo == (10):
print("The quiz has finished. your score is ",score)
again = input("Do you want to play again? (Y/N)")
gamesplayed = gamesplayed + 1
if again == ("Y") or again == ("y"):
theo = 0
timesplayed = timesplayed + 1
elif again!=("y") or again!=("Y"):
print("well done your final score was ",score," you played
",timesplayed," times")
, если оценка больше, чем высокая оценка (импортируемая из csv, тогда перезаписать оригинальную высокую оценку своим одним + вашим именем)