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 trialgabrieL faurE
1,697 Pointsdisemvowel challenge
Hi i allready did the disemvowel challenge, but with another method, i don know why with this code i cant remove the last "e"
word ="bUVOnEe"
def disemvowel(word):
l=len(word)
print(l)
word=list(word)
a=0
while a <=l:
try:
if word[a] in ["a","e","i","o","u","A","E","I","O","U"]:
del word[a]
a+=1
else:
a+=1
except IndexError:
a+=1
print(word)
disemvowel(word)
1 Answer
gabrieL faurE
1,697 Pointsok got it
def disemvowel3(word):
l = len(word)
word = list(word)
word2 = word
print(word)
vocals = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
a = 0
b = 0
while a <= l:
print("a = {}".format(a))
try:
if word[a] in vocals:
del word2[a]
print("delete {}".format(a))
print(word2)
else:
print("els{}".format(a))
a += 1
except:
print("ex {}".format(a))
a += 1
Justin Henley
2,968 PointsJustin Henley
2,968 PointsCan you please explain to me this code. I looked through it trying to understand, but am struggling. I copied and tried running it and it returned a bunch of seemingly nonsensical values