-1
#functions
def main_menu():
    print('If you want to read the rules select:1, to play the game select:2, to quit select 3.')
    branch = int(input('What do you want to do:\n'))
menu = input('Type: main_menu()\n')
while branch == 1:
    print('Hello to the rules')
    main_menu
while branch == 2:
    print(branch)

This will later become a number guessing game, where the function calls up the main menu, any help to call up the function?

  • 1
    This question is not clear about the obstacle you encountered. Is this the first time you try to call a function? Did you try calling the function like other functions? With what result? Do you have problems with the needed context in which to call? Please have a look at [ask] and generally [tour]. – Yunnosch Dec 07 '20 at 23:26

3 Answers3

0
from library import function_name

This is how you can load in main and than utilize where you want.

as a reference, I am giving you link below.

importing function from library or file to main file

ML85
  • 709
  • 7
  • 19
0

Are you looking for this:

def main_menu():
    print('If you want to read the rules select:1, to play the game select:2, to quit select 3.')
    branch = int(input('What do you want to do:\n'))
menu = input('Type: main_menu()\n')
while branch == 1:
    print('Hello to the rules')
    main_menu
while branch == 2:
    print(branch)
main_menu() # just do this

That's how you call a function in Python. Add a () in the function name

ppwater
  • 2,315
  • 4
  • 15
  • 29
0

Just use:

main_menu()

That's how you call a function in Python.

Gavin Wong
  • 1,254
  • 1
  • 6
  • 15