我必须创建一个类,其中有一个函数可以修改对象中变量的值。 犬类:
class dog:
def __init__(self,x,y,z):
self.x=x
self.y=y
self.z=z
def __str__(self):
return print("mi nombre es "+self.x)
def bark(self,otr):
if self.z*self.y>otr.z*otr.y:
print("gano: "+self.x)
int(otr.x)=int(otr.x)-2
if self.z*self.y<otr.z*otr.y:
print("gano: "+otr.x)
int(self.x)=int(self.x)-2
但当我试着运行它时,它会给我一个“cant assign function to call”错误,我也想知道这是否是正确的方法
我刚刚修改了你的狗课。在代码中查看我的修改和注释below:- 你知道吗
相关问题 更多 >
编程相关推荐