1

I am working on a program and have come up with an error I don't usually face. My error is quite simple, yet I cannot wrap my head around a way to get past this problem. Thanks for helping.

Code:

budget = 50
depositAmount = input("Please enter an amount you would like to add")
if depositAmount > budget:
    print("Sorry, you do not have the required funds to join. You have been exited.")
else:
    #DO THE REST OF THE PROGRAM#

So in short terms, I will be adding values to the budget variable in the future, thats why I can't use the if statement and say less than 50, because the budget variable may be different. How do I make sure that if the user inputs a number greater than the variable value (or lower) they will be given an error message?

Matt
  • 55
  • 6

1 Answers1

0

Convert depositAmount to number with int built-in before comparing with budget, to do it replace your if condition from

if depositAmount > budget:

to

if int(depositAmount) > budget:
Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82