When I run this code:
li=["It","is","funny","how","I","fiddled","with","this"]
for i in range(0,len(li)):
word=li[i]
for j in range(0,len(word)-1):
if word[j] == word[j+1]:
li.pop(i)
break
print(li)
My desired output is:
['It','is','how','I','with','this']
However, I get the following error message:
Traceback (most recent call last):
File "fiddle.py", line 3, in <module>
word=li[i]
IndexError: list index out of range
Please point out the mistake in my code.