Help me to turn this into a function and make this infinite. [School project]
Hey everyone, I need some help for my school project. I need to create a program that generates random numbers, shows them to you, and then asks you the result of the sum. If the answer is correct, it adds some points to the score, and if you fail, your score will remain the same, but another sum will appear. Then, I should be able to choose if I want to do the sum or If I want to exit the program. Here is my code: def Funcio1(): # Variables puntuació = 0 usuari = str(input("Com et dius? ")) edat = str(input("Quina edat tens? ")) while True: x = random.randint(0,10) y = random.randint(0,10) z = x + y print (str(x) + "+" + str(y)) resultat = int (input()) if resultat == z: print ("Correcte") puntuació = puntuació + 5 print ("Tens aquests punts:", puntuació) else: if resultat != z: print ("Malament!") parar = input("Vols parar? ") if parar == ("si" ): print (usuari + ", has aconseguit " + str (puntuació) + " punts") break else: continue Sorry for the quality of the code, it's my first big projecte since I started learning python a month ago.