I can't figure out why I get the error: TypeError: Can't convert 'int' object to string implicity
This is the relevant code for the class:
class Pig():
def __init__(self, name, age, weight, value):
self.name = name
self.age = age
self.weight = weight
self.value = value
def runAndGainValue(self, value):
self.value += value #This is where the error occur.
def __str__(self):
a = self.name + " "
a += str(self.value) + " "
return a
And here's the part of the code for the main program:
elif work == "2":
yourfarm.printAnimals()
print ("blablablabla")
for pig in p:
pig.runAndGainValue(5)
yourfarm.printAnimals()
And I can't figure out why I get this error. I've tried searching for it but I am new with programming so I have a lot of trouble with interpreting a totally different code but with the same problem. Very much grateful for your help ahead.