我正在使用一种方法向我返回押金的值,但是它显示语法错误。
class Account:
def __init__(self,owner,balance):
self.owner= owner
self.balance= balance
def deposit(self,amount_in):
return self.balance+=amount_in
def withdraw(self,amount_out):
if amount_out>self.balance:
print("Ther is not enough balance in your account")
else:
self.balance= self.balance- amount_out
def __str__(self):
return str(self.owner) + ' ' + str(self.balance)
错误:
File "<ipython-input-101-7e8824d5cebe>", line 7
return self.balance+=amount_in
^
SyntaxError: invalid syntax
答案 0 :(得分:1)
您正在尝试退回作业。
只需将您的代码更改为此:
def deposit(self,amount_in):
self.balance+=amount_in