first import random. then use "random.randint(1, 10)" to generate a number 1 - 10. you can repeat in different ways. I'll show you down below
You can use range
Edit - I just realized you want a function repeated. In that case just execute the function in the lines set to repeat
You can use range
for x in range(1, 10): #Will happen 10 times if Variable == 0: #0 is attack num = random.randint(1, 10) elif Variable == 1: #1 is defense pass #Do stuffYou can use while
while defeat == False: if Variable == 0: #0 is attack num = random.randint(1, 10) elif Variable == 1: #1 is defense pass #Do stuffYou can have a variable for keeping track of who's turn it is and a function that will trigger another function based on who's turn is is. If it's the player's turn it will trigger this function. If not it will trigger this function. Hope this solves your problem. Also remember to import random
Edit - I just realized you want a function repeated. In that case just execute the function in the lines set to repeat