Solution for IndexError: list assignment index out of range😭
This is the code ---------------------------------------------------------------------- def countApplesAndOranges(s, t, a, b, apples, oranges): ap=[] oran=[] for i in range(len(apples)) : ap[i]=apples[i]+a for i in range(len(oranges)) : oran[i]=oranges[i]+b p=0 og=0 for i in range(len(apples)-1) : if (ap[i]>s and ap[i]<s): p+=1 for i in range(len(oranges)-1): if (oran[i]>s and oran[i]<t): og+=1 print (p) print (og) ---------------------------------------------------------------------- The error I am facing is this: ---------------------------------------------------------------------- Traceback (most recent call last) File "Solution.py", line 52, in <module> countApplesAndOranges(s, t, a, b, apples, oranges) File "Solution.py", line 14, in countApplesAndOranges ap[i]=apples[i]+a IndexError: list assignment index out of range ---------------------------------------------------------------------- Thanks for any possible help out there