class MyList(list): def __mul__(self, other): if isinstance(other, MyList): return MyList((x,y) for x in self for y in other) else: return super().__mul__(self, other) a = MyList([1, 2, 3])b = MyList([4, 5, 6, 7])print(a*b)
Standard input is empty
[(1, 4), (1, 5), (1, 6), (1, 7), (2, 4), (2, 5), (2, 6), (2, 7), (3, 4), (3, 5), (3, 6), (3, 7)]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!