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 trialNoah Harness
1,383 PointsI suck at programming and its making me upset
I don't know how to do this shit.
blank_word = ""
vowels = ["a", "e", "i", "o", "u"]
def disemvowel(word):
for letter in word:
if letter not in vowels:
blank_word += letter
print(blank_word)
1 Answer
Umesh Ravji
42,386 PointsHi Noah, you pretty much have the answer there :) You do know how to do it.
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] # have to include both upper and lower cases
def disemvowel(word):
blank_word = "" # better as a local variable inside the function
for letter in word:
if letter not in vowels:
blank_word += letter
return blank_word # remember you want to return this, not print it out
SC3 Rocks
33,474 PointsSC3 Rocks
33,474 Pointsif you want to avoid including capitals and lowercase letters in
vowels
, you can just checkif char.lower() not in vowels:
. That way, no matter what the case ofchar
is, it'll still be in the list.