Jun-20-2019, 05:56 PM
how do I call functions from a dictionary?
def foo(): print('foo') def bar(): print('bar') foobar = { 'foo': foo, 'bar': bar } command = input('foo or bar, Choose one. ') foobar[command] # returns nothing. print(foobar[command]) # prints memory location.
Output:PS C:\Users\User\Desktop> python test.py
foo or bar, Choose one. foo
<function foo at 0x0380C030>
PS C:\Users\User\Desktop>