#week 8 - starter program 1

def addScore():
    name = input("Enter the name: ")
    score = input("Enter their score: ")
    reset = input("Would you like to reset the scores file? (Y/N): ")
    if reset.lower() == "y":
        file = open("scores.txt", "w")
    else:
        file = open("scores.txt", "a")
    file.write(name + " " + score + "\n")
    file.close()

def showScores():
    file = open("scores.txt", "r")
    for line in file:
        items = line.split(" ")
        print("Name:",items[0]+", Score:",items[1])
    file.close()

def highest():
    file = open("scores.txt", "r")
    highest = ["","0"]
    for line in file:
        items = line.split(" ")
        if int(items[1]) > int(highest[1]):
            highest = items
    print("Highest Score:\nName:",highest[0]+", Score:",highest[1])
    file.close()

repeat=True
while repeat==True:
    choice=input("1. Add Score\n2. Show Scores\n3. Show Highest Score\n")
    if choice=="1":
        addScore()
    elif choice=="2":
        showScores()
    elif choice=="3":
        highest()






