Reputation: 131
I want to compare vogals that I put in one variable, and see if they are not the same. I only want to output the vogals that exist in that variable, but I don't want it to appear the same vogal multiple times.
My code:
lista = []
for vogal2 in palavra:
if vogal2 in 'aeiou':
lista.append(vogal2)
x ='0'
for val in lista:
y = lista.index(val)
if val == x:
lista[y] = []
x = val
print (lista)
The output:
>>> Enter a word: inconveniente
['i', 'o', [], 'i', 'e', 'e']
I want the output this way:
>>> Enter a word: inconveniente
['i', 'o', 'e']
Can you help me? I'm using python 3.5.0
Upvotes: 0
Views: 293
Reputation: 1032
This is a different code doing the same thing:
word = input("Enter a word: ")
output = []
for letter in word:
if letter in "aeiou" and not letter in output:
output.append(letter)
print(output)
Upvotes: 1