I want to run a function inside a While Loop, but I cannot figure out a way to. I searched all over for the answer, and nothing seems to relate to my answer at all. Help!
Here is the function.
def check(Money): print('You have ' + str(gold) + ' gold.')
Here is the part I want to insert the function into, but I cannot figure out a way to.
if str(var3) == ('Check(Money)'): print('You have ' + gold + ' gold.') #is there any way to run the function Check(Money)? break
I tried using
exec in that part, like this:
if str(var3) == ('check'): print('What would you like to check?) checkvar1 = input() if str(checkvar1) == ('check(Money)'): exec (check(Money))
And it came up with this:
Traceback (most recent call last): File "C:Python27Maze Game.py", line 53, in <module> exec (check(Money)) NameError: name 'Money' is not defined
I was pretty sure this wouldn’t work, but it was a start. (Note: Why this would not work is not the question I’m asking). My question is: Is there any way to place the function
check(Money) inside my While Loop?