'Python Calculator having issues
So I've added a feature to write percentages efficiently, all you would have to do is have a number, say 6, then press percentage, and the calculator would automatically write out 0.06. It's all working well when you start to type out the expression for the calculator:
But when you press the equal sign, thats when things go bad:
Now because I'm horrible at math, I literally thought this was the correct answer, so now i can finally move on to other things, right? But when I googled it, it said that 6*0.06 is 0.36, not 36.
Here's where things get a little bonkers again, when I do 6/0.06, I get 1, not 100, so that means whenever I divide, I get something 100 times lower than the actual answer, whenever I multiply, I get something 100 times higher than what I asked for.
Here is the percent function:
def percent():
global expression
last_num = expression[-1]
percent = int(last_num)/100
equation.set(f"{expression[:-1]}{percent}")
Any help would be appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


