I have this code, which calls a function based on your input key. For example, if you chose pf
, it would call the pf
function, my_function(20)
.
My problem is, I know how to call a function without arguments, but I don't know how to do it with arguments. It runs all the functions right now because of the ()
, but how do I give it argmuents and still call it? Would I have to create a seperate list of arguments?
function_map = {
'pf':['finds the prime factors of a number',my_function(20)]
'cs':['solves a quadratic by completing the square',m.complete_square()]
'sr':['simplifies a radical',m.simplfy_radical(input('> '))]
}
for d in function_map.keys():
print('{} - {}'.format(d,function_map[d][0])
selection = input('Input keycode >>> ')
if selection in function_map.keys():
function_map[selection][1]()