I'm learning Python on my R.Pi and I've hit a small snag. It seems to me that the following code would leave the "inputchecker" function open in memory while it routes back to the "getinput" function.
Is this bad code? Should it be done very differently?
def getinput(i):
if i == 1:
first = input("Would you like A or B? ")
inputchecker(1, first)
elif i == 2:
second = input("Would you like C or D? ")
inputchecker(2, second)
def inputchecker(n, userinput):
def _tryagain_(n):
usage(n)
getinput(n)
if n == 1:
if userinput in ("A", "B"):
print("You chose wisely.")
getinput(2)
else:
_tryagain_(n)
elif n == 2:
if userinput in ("C", "D"):
print("You chose wisely.")
else:
_tryagain_(n)
def usage(u):
if u == 1:
print("Usage: Just A or B please.")
if u == 2:
print("Usage: Just C or D please.")
getinput(1)