How do I iterate through two lists without the use of nested "for" loops?
the index between the two lists doesn't necessarily have to be the same
more specifically I am coding a function that takes a list of strings and a list of banned words. If any of the banned words are in each one of the strings, that whole string gets deleted.
I tried doing:
for word in bannedWords:
for string in messages:
if word in string:
messages.remove( string )
This, however, doesn't work because the string variable is used in the "for" loop, so removing the string from messages will mess up the "for" loop. What is a better way to implement? Thanks.