Python 取款功能'<';在';非类型';和';int';
我刚开始学习python。我遇到了以下错误Python 取款功能'<';在';非类型';和';int';,python,python-3.x,Python,Python 3.x,我刚开始学习python。我遇到了以下错误 ”因为当余额
”因为当
余额
时,您不返回任何内容,当前余额
等于无。您不能使用,因为您没有在if语句中返回任何内容,当前余额
结果为零。即使余额
小于金额
,您也需要返回余额
,否则您会将当前余额
设置为无
,因为if语句不返回任何内容。然后,无
金额
引发错误。
current_bal = 100
def withdrawl(balance, amount):
if balance < amount:
print('You have not enough money')
else:
balance -= amount
print('You have withdrawn {}. Your new balance is {}'.format(amount, balance))
return balance
current_bal = withdrawl(current_bal, 100)
current_bal = 100
def withdrawl(balance, amount):
if balance < amount:
print('You have not enough money')
else:
balance -= amount
print('You have withdrawn {}. Your new balance is {}'.format(amount, balance))
return balance
current_bal = withdrawl(current_bal, 100)```