im a beginner in python and don't understand the following: i define a class and a list. When I want to print the list after appending it, I don't get strings, although I have a method that should return me a string, right? I don't see what is wrong here.. :/ I would expect the outcome to be [14,12]... If someone knows what I did wrong, please tell me :/
class av:
def __init__(self, num):
self.num = num
def __str__(self,num):
self.num = num
return str(self.num)
lst = []
lst.append(av(14))
lst.append(av(12))
print(lst)
outcome:
[<__main__.av object at 0x102503dd0>, <__main__.av object at 0x102505d90>]