I'm writing a simple program and I just can't get out of this loop. What i want to do is if withdraw amount is greater than your balance, go to the while loop. The while loop should get a new input and check if new input is greater than balance, if it is repeat, if not go to the else, which is where i print the balance
class Account(object):
balance = 0
accountNumber = 0
def __init__(self, f, l, ssn, b):
self.firstName = f
self.lastName = l
self.socialSecurity = ssn
self.balance = b
self.accountNumber = randint(0, 10000)
def __str__(self):
return self.firstName + " " + self.lastName + \
"'s balance is $" + str(self.balance) + \
". Your account Number is " + str(self.accountNumber)
def deposit(self, amount):
depositAmount = amount
balance = self.balance + depositAmount
print(str(depositAmount) + " has been deposited into account "
"#" + str(
self.accountNumber) + " Your balance is "
"now " + str(balance))
return self.balance
def withdraw(self, amount):
withdrawAmount = amount
balance = self.balance - withdrawAmount
if float(withdrawAmount) > float(balance):
while float(withdrawAmount) > float(balance):
print("Insufficient Funds, Enter new amount")
withdrawAmount = raw_input(">")
else:
print(str(withdrawAmount) + " has been taken out of account "
"#" + str(
self.accountNumber) + " Your balance is "
"now " + str(balance))
testOne = Account("John", "Smith", "1111", 1000)
print(testOne)
print(testOne.accountNumber)
testOne.deposit(200)
testOne.withdraw(5000)
my problem is that i'm stuck in the while loop no matter what i put it says enter new amount