Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialaustin bakker
7,105 Pointsfor vowels in word
Hello i was wondering if i could use the for function to make my code simpler. I am not sure on how to make it work. Can you help me?
def disemvowel(word):
rmvowels=list(word)
vowels='a','A','e','E','i','I','o','O','u'
for vowels in rmvowels:
try:
rmvowels.remove(vowels)
except ValueError:
pass
else:
return word
1 Answer
Krishna Pratap Chouhan
15,203 PointsI would try something like this.
lis1 = ["a", "b", "c", "d", "e"]
lis2 = ["b", "d"]
result = list( set(lis1) - set(lis2) )
#result will have, ["a", "c", "e"]
hope this helps.
Krishna Pratap Chouhan
15,203 Pointsactually the answer would be ["c", "e", "a"] (optimization thing).
Krishna Pratap Chouhan
15,203 PointsKrishna Pratap Chouhan
15,203 Pointshey austin, could you try printing vowels after giving it a value?