lis.py

class mylist:
        def __init__(self,l):
                self.data = l;
        def __add__(self,l):
                self.data = self.data + l
        def __repr__(self):
                return self.data

main.py

from lis import*

x = mylist([1,2,3])
x = x + [4,5]
print x

Why is it printing None? What do I did wrong,Thanks.

Some print statements should clear up some things. And note that your __add__ function will yield an error but that is something to address after you get this part working.

class mylist:
        def __init__(self,l):
                self.data = l;
        def __add__(self,l):
                self.data = self.data + l
        def __repr__(self):
                return self.data
 
x = mylist([1,2,3])
print x
print x.data

#x = x + [4,5]
#print x

i guess my problem was that i didnt return from __repr__ with `self.data` and in main.py I shouldnt done directly x + [4,5].