Im creating a rock paper scissors game which consists of a subprogram containing the single player game, which is stored on a different file and imported to the main program which runs it. In the single player game the player has the option of returning to the main menu which is part of the runner file however i cant work out how to allow the player to do this. Any suggestions?
I tried to import the runner file into the singleplayer program and call a function from runner there but it caused an error: NameError: name ‘runner’ is not defined
Code for Runner file:
#RPS Runner
from RPS_singleplayer import *
from RPS_multiplayer import *
#The actual runner
def runner():
exitCalled=False
print("Welcome to Rock Paper Scissors")
print("Main Menu n1. Singleplayern2. Multiplayern3. Exit")
grabUserInput = int(input("Enter an option:"))
while exitCalled!= True:
if grabUserInput ==1:
print("taking you to singleplayer mode... please wait")
singleplayer()
elif grabUserInput==2:
print("taking you to multiplayer mode... please wait")
multiplayer()
elif grabUserInput==3:
exitCalled=True
exit()
else:
print("Invalid Input. Try Again")
grabUserInput = int(input("Enter an option: "))
runner()
section of Code from singleplayer file:
choice = input("Would you like to play again or return to menu? Y/N/M?: ")
if choice == "y" or choice == "Y" or choice == "yes":
rpscpu()
elif choice == "n" or choice == "N" or choice == "no":
print("Thanks for playing!")
quit()
elif choice == "M" or choice == "m" or choice == "menu":
runner()```
user26366849 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.