I want to add a scoring system on my code. Every time that the player gets a correct answer, a 5 point score will be added to the player's overall score. This is my code below:
def easyLevel():
n = 2
while n <= 7:
pattern = random.choice(string.ascii_lowercase)
for i in range(n-1):
pattern = pattern + " " + random.choice(string.ascii_lowercase)
print("The pattern is: ")
print(pattern)
easyAns = str(input("What was the pattern?: "))
if easyAns == pattern:
n = n + 1
print("That's correct!")
else:
print("Sorry, that's incorrect.")
break
How can I save the scores in a file? Along with the last pattern that the player answered correctly.
Also, is there a way I could print the pattern and score outside of this function? if so, how can I do that?
Would appreciate your help. Thank you!