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 trialMatt Fuller
8,831 PointsPython Collections (2016, retired 2019) - challenge task 1 of 1
Took quite a break from self learning coding, absolutely clueless with this one. Can anyone please explain?
def disemvowel(word):
vowels = ("a", "e", "i", "o", "u")
word = input("what word would you like to disemvowel?\n> ")
if not vowels == 'word':
exit()
else:
print ("Removing vowels.")
word.remove(vowels)
1 Answer
Jeff Muday
Treehouse Moderator 28,720 PointsSince this is a coding Challenge. It has an automated grader, so you are NOT supposed to user interactive input() function.
But you look like you do understand some Python concepts, so let's build on that.
There are many correct approaches to this problem. One way is to make a new_word that does not contain vowels. This is accomplished by iterating over the word letter by letter and checking if the letter is NOT a vowel.
Hint: the grader will check both upper and lower case vowels too!
def disemvowel(word):
vowels = 'aeiouAEIOU'
# the new_word starts as an empty string
new_word = ''
for letter in word:
# check if the current letter is NOT a vowel, copy it into the new_word
# and the vowels are skipped
if not(letter in vowels):
new_word += letter
# finally, return the new_word
return new_word
Kito Middleton
3,340 PointsKito Middleton
3,340 PointsYou need to iterate over the string to check if any of those vowels are equal to any of the letters in the string being passed to function...