import easygui as eg
import sys
version = 'Percentage Calculator'
Options = [ 'Percantage Increase', 'Percentage Decrease' ]
button = eg.buttonbox ('What would you like to calculate', title = version, choices = Options)
if button == Options [0]:
enter = eg.enterbox ('Please enter a number between 0 and 999.', title = version, strip=False)
if enter < '0' or enter > '999':
eg.msgbox ('please choose a number between 0 and 999.', title = version, ok_button='OK')
sys.exit()
enter2 = eg.enterbox ('please enter a number between 0 and 999, that is bigger than the first number.', title = version, strip=False)
if enter2 < '0' or enter2 > '999':
eg.msgbox ('please choose a number between 0 and 999.', title = version, ok_button='OK')
sys.exit()
elif enter2 < var enter:
eg.msgbox ('please choose a number bigger than the first number.', title = version, ok_button='OK')
sys.exit()
Subtract = enter2 - enter
print (Subtract)
this is my code... as you can see, near the bottom, it says 'enter2 - enter' i want this to subtract the second number that the user put in from the first number but it just says...
Traceback (most recent call last):
File "C:\Users\olitr_000\Desktop\PYTHON\Percentage Calculator\Percentage Calculator.py", line 22, in <module>
Subtract = enter2 - enter
TypeError: unsupported operand type(s) for -: 'str' and 'str'
what can i do so that say enter 1 equals 55 and enter2 = 198 how would i get it so that it does 198 - 55?!
please help, i you need any more information please notify me.
intas they are string by default.int(enter)andint(enter2)enter2 < '0' or enter2 > '999'checks wont work properly. You would have to convert tointbefore these checks