from time import sleep
total = 0
def calcu():
import random
num1 = random.randint(1,20)
import random
num2 = random.randint(1,100)
sum = num1 + num2
answer = int(input("What Is " + str(num1) + " + " + str(num2) + " = "))
if answer == sum:
print("Correct\n")
sleep(3.00)
total = total + 1
calcu()
else:
print("Incorrect The Correct Answer Is " + str(sum) + "\n")
sleep(3.00)
print(total)
calcu()
How do I add a scoring system to the loop without resetting the score back to 0? sorry bad grammar, also new to this...
p.s got the answer
total = 0
def calcu(total):
import random
num1 = random.randint(1,20)
import random
num2 = random.randint(1,20)
sum = num1 + num2
answer = int(input("What Is " + str(num1) + " + " + str(num2) + " = "))
if answer == sum:
print("Correct\n")
sleep(3.00)
total = total + 1
calcu(total)
else:
print("Incorrect The Correct Answer Is " + str(sum) + "\n")
sleep(3.00)
print(total)
calcu(total)
How do I add a scoring system to a loop without resetting the score to 0?
Define the
totalas a global value in: