Answer the question
In order to leave comments, you need to log in
How to run code again in Python?
I wanted to make a simple game in Python. But here's the problem. I don't know what command to run the code again. I went to Google and there were such questions ... But the answers to them did not help me. I need some kind of PiP, or a function to run the code again. Let's not use the method of creating a function))
If this is the code, I agree it's simple, but I'm still learning))
import random
import time
#ask
random = ( random.randint(1, 2) )
number = float( input( 'Enter the number 1 or 2. If you guess right, you'll get a prize!' ))
#guessed
if random == number:
a = str( input( 'You guessed it!! Give me your elect wallet number and we'll get the money. :' ))
print( 'Excellent!! The money will come in 5 minutes.' )
exit = input( 'The program is finished! The Trojan will exit in 15 seconds.\n To exit the program press f\n Thank you for watching to the end))) ' )
time.sleep(15)
elif exit == 'f':
SystemExit(1 .
_
_
_
_
_
_ ' or b == 'yes':
print( 'd' )
###########here I need to run the code again################# #########################################
Answer the question
In order to leave comments, you need to log in
Judging by the description, you want to loop it, not restart it. You can add a loop after the imports, then after the code is executed, it will return to the beginning and "launch the code again", and so on ad infinitum, or until you stop it yourself by closing the window / adding a condition with to the code. while True:
break
You need it in the frontend, it is considered normal to install a module there to supplement the line with indents.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question