I have a dictionary switcher
in this piece of code:
def a():
print("A")
def b():
print('B')
def switch(mode):
switcher = {
'a': a,
'b': b,
'ab': (a, b)
}
switcher[mode]()
switch('a')
If I use switch('a')
I get the output:
A
So far using switch('ab')
returns an error:
TypeError: 'tuple' object is not callable.
How would I be able to execute both a
and b
using switch('ab')
?