For example, if the input is "a" then run a function and if "b" then another function. The only reason that I am doing this is that I have a really long code with lots of functions What I was thinking was this.
userinput = input("Input:")
def a():
print("You entered A")
def b():
print("You entered B")
if userinput == "a":
a()
if userinput =="b":
b()
This is what I would normally do but it would be too long. The code that I am doing will have many functions so it would be inefficient. I am trying to find a code that will not use a lot of if functions. My code would have over a hundred functions according to what the user has entered. This is just an example to show the functions. I was thinking of this.
userinput = input("Input:")
def a():
print("You entered A")
def b():
print("You entered B")
[userinput]()#I did input in the bracket so if someone enters "a" for example then it would run function a and if "b" then it runs function b
This is what I want to do but it doesn't work. If anyone could help me I would be very thankful. All the other ones I looked for did not have any alternatives other than using if else.