0
Can someone help me?
class sorvete():
def __init__(self,sabor, recipiente):
self.sabor= sabor
self.recipiente= recipiente
self.ml= 0
def sabor(self):
print("O sabor que pediu é: ", (self.sabor))
def recipiente(self):
print("O recipiente que pediu é: ", (self.recipiente))
def quantidade(self,ml):
self.ml= self.ml + ml
sorvete1=sorvete('Morango','Casquinha')
print(sorvete1)
print(sorvete1.sabor())
print(sorvete1.recipiente())
print(sorvete1.quantidade(500))
Error:
Typeerror: 'str' Object is not callable
You have defined a method with the same name as an attribute. In this case, when you call
sorvete1.sabor()
Python searches for the attribute that is string. Rename one of the two.– Paulo Marques
Adding to the @Paulomarques comment, you can access the attributes this way
sorvete1.sabor
andsorvete1.recipiente
See more here– Bernardo Lopes
It worked!! I thank you very much
– Matheusxd87