def MainMenu ():
print("Enter 1 to set values")
print("enter 2 to display values")
MainMenuInput = int(input("Enter: "))
if MainMenuInput == "1":
setgen()
MainMenu ()
elif MainMenuInput == "2":
print (fjuv)
def setgen ():
fjuv = int(input("Amount of juveniles between 0 and 25?"))
MainMenu ()
MainMenu ()
setgen ()
How to do make it so on MainMenuInput == 2
it prints the values from MainMenuInput == 1
which is the code in def setgen?
为此,您需要/可以通过将global
放在在定义变量之前运行的代码的初始化部分来定义全局变量。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.