Now, I am practicing with lists, So I created 2 lists, so basically I search in one of them for values that are not in the second list and if it is not there I want to remove it from the list. But the results do not have all the entries removed.
Here is what I have done:
vocales = ["a","e","i","o","u"]
found = ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
for i in found:
if i not in vocales:
print(i, end=" ")
print(i not in vocales,end=" ")
found.remove(i)
print(found)
input("press enter to continue")
So when in run the program all the consonants are not recognized
Here is the result:
b True ['a', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
h True ['a', 'i', 'o', 'u', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
True ['a', 'i', 'o', 'u', 'l', 'c', 'm', 'e', 's', 't']
press enter to continue
m True ['a', 'i', 'o', 'u', 'l', 'c', 'e', 's', 't']
press enter to continue
s True ['a', 'i', 'o', 'u', 'l', 'c', 'e', 't']
press enter to continue
But if I run the code without removing any value from the list, it recognizes all the letters.
vocales = ["a","e","i","o","u"]
found = ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
for i in found:
if i not in vocales:
print(i, end=" ")
print(i not in vocales,end=" ")
print(found)
input("press enter to continue")
and this is the result:
b True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
h True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
l True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
c True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
m True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
s True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
t True ['a', 'b', 'i', 'o', 'u', 'h', 'l', ' ', 'c', 'm', 'e', 's', 't']
press enter to continue
All consonants are recognized, could you advice how you could remove of the items that don't appear in a list