0

Problem in calculator

In my function, there are two variables, namely x and y. In calculating some operation which involves only one number to deal with, I want to cancel the second number. As it is an input, one has to input second number even when the operation doesn't involve it. What to do? Do I have to make another function for such types of operations? Or is there such provision in python? Please help. https://code.sololearn.com/cSP196epWeAF/?ref=app

11th Mar 2022, 9:53 AM
Tathya
5 Réponses
+ 1
You can use try/except It will try to run input, if input dont exist it will set 1 to this value https://code.sololearn.com/cgf5ysh3Mt3K/?ref=app
11th Mar 2022, 10:37 AM
PanicS
PanicS - avatar
+ 1
Why you use so many if elif? Use dictionary: di ={ "multiplication": m, "division": d, "addition":a, #etc }
11th Mar 2022, 11:27 AM
Shadoff
Shadoff - avatar
+ 1
Shadoff Actually I am a beginner to Python and don't know much about it. As mentioned, this is my first code made by me and I was just putting my knowledge I have gained till then to make a code without using any advanced things.
14th Mar 2022, 1:46 PM
Tathya
0
Tathya , have a nice journey, then.
14th Mar 2022, 2:34 PM
Shadoff
Shadoff - avatar
0
Shadoff Thanks
15th Mar 2022, 1:01 PM
Tathya