The objective I had was to remove all words in a list that contained letters from user input
import pandas as pd
filtered = ['d','dd','ddd','dddd','ddddd','dddddd']
filtered_lc = [x.lower() for x in filtered]
str = input("Input wrong letters (enter blank to skip): ")
for word in filtered_lc:
for letter in str:
if letter in word and word in filtered_lc:
filtered_lc.remove(word)
df = pd.DataFrame(filtered_lc)
print("-----------------------\n", df)
Desired output should be nothing
Output I got:
-----------------------
0
0 dd
1 dddd
2 dddddd
Could anyone explain why it is only processing for the 1st, 3rd and 5th word in the list please? Thank you