0
whats wrong in this code
class arr: def __init__(self,l): self.l=l def __add__(self, other): i=0 p=[] if len(self.l)==len(other.l): while i<len(self.l): p.append(self.l[i]+other.l[i]) return p p=arr([1,2,3]) q=arr([1,2,3]) print(p+q)
2 Respostas
+ 3
You forgot to increment i within that while loop, better option is to use a for loop so you won't forget stuff like this in the future!
+ 1
oh thanks👍👍