I am aware that Python doesn't have a switch case like C++, but I'm trying to figure out how to go about it and found something, but not sure if it's implemented correctly.
So I have something like:
def choiceone():
choiceone statement here
def choicetwo():
choicetwo statement here
def switching(x):
switcher= {1: choiceone(),
2: choicetwo(),
}
func = switcher.get(x, 0)
return func()
def main():
user_input=input("Choice: ")
switching(user_input)
main()
It's great that it prompts user for input, but regardless of number I write, it always runs choiceone
.
I'm trying to see how I can go in invoking a function based on user selection.