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
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
+ 1
Why you use so many if elif? Use dictionary:
di ={
"multiplication": m,
"division": d,
"addition":a,
#etc
}
0
Tathya , have a nice journey, then.
0
Shadoff Thanks