I faced an issue with my code where the loop stops running once it removes the list from the list of list.
data=[["why","why","hello"],["why","why","bell"],["why","hi","sllo"],["why","cry","hello"]]
for word_set in data:
if word_set[-1]!="hello":
data.remove(word_set)
print(data)
My desired output is
[['why', 'why', 'hello'], ['why', 'cry', 'hello']]
but the output is
[['why', 'why', 'hello'], ['why', 'hi', 'sllo'], ['why', 'cry', 'hello']]
How do I make the loop go on till the end of the list?