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 trialLouigi Richardson
Courses Plus Student 3,448 PointsRemoving the vowels not working!?
when i run this script in another editor is seems to work to perfection removing the Upper and Lowercase vowels. Why isn't it been successful here?
def disemvowel(word):
test1 = list()
test1.extend(word)
try:
for i in test1:
if i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u':
test1.remove(i)
except ValueError:
pass
try:
for j in test1:
if j == 'A' or j == 'E' or j == 'I' or j == 'O' or j == 'U':
test1.remove(j)
except ValueError:
pass
s = ""
text_good = s.join(test1)
word = text_good
return word
2 Answers
reanimator313
6,005 Pointsloop through word not through list of word.
for i in word:
# code
for j in word:
# code
Louigi Richardson
Courses Plus Student 3,448 PointsAhh now i get it! Thank you for you insight sir! Very helpful, been going 2 days at it.
Louigi Richardson
Courses Plus Student 3,448 PointsLouigi Richardson
Courses Plus Student 3,448 PointsThe request is that that the function take a single word:S. I tried the for i in word, still no avail
reanimator313
6,005 Pointsreanimator313
6,005 Pointsyour code with my changes
When you loop through a list, and remove an index, the lop is going like this:
I hope you understood. :)