Answer the question
In order to leave comments, you need to log in
How can one .py file run a function from another file?
How can I run a function from another file?
type
from main import main # импорт нужной функции
start_game = input("start game? yes/no")
if start_game == "yes":
main()
elif start_game == "no":
quit()
Answer the question
In order to leave comments, you need to log in
when importing, the file is immediately launched
if __name__ == '__main__':
Do it like this:
Replace with
and withfrom main import main
import main
main()
main.main()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question