r/PythonLearning
•
u/shubham_555
•
Sep 13 '26
•
1
Showcase The Bank Project
Last Post - https://www.reddit.com/r/PythonLearning/s/kGqwMS9HUH
Github Repo - https://github.com/Dev-4-All/bank.git
242
Upvotes
View all comments
Show parent comment
2
u/FoolsSeldom Sep 14 '26
All good. Glad you researched the structural pattern matching (yes, it is advanced).
A few more ideas for your consideration ...
Another common approach to calling functions based on an option is to use a dictionary,
where
addnumsandsubnumsare the names of your functions.No
iforcaserequired, you just call the correct function to carry out the operation required.You could even build a menu of options and calls:
and now you can display a menu of options including the operator to use and a description (first entry in the value
tuple)The call would then be,
and you could validate options based on the keys,
if operator in menu.keys():You could even add a
qorxto quit/exit option and give it aNonefor the function to call. If the function returnedis Noneyou know to exit.