I'm doing a small example with classes in Python but I want you to print a list of elements so use __str__
but I mark the error that it was not a type string
here is my code:
class intSet(object):
def __init__(self):
self.vals = []
def insert(self, e):
if e not in self.vals:
self.vals.append(e)
def __str__(self):
return self.vals
s = intSet()
s.insert(1)
s.insert(4)
s.insert(6)
print(s)
Is there a function that returns a list?