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 trialSteve Mohimani
2,365 PointsStuck on this one... modified word is not returning to console or printing - help!
Tried to run this code through repl.it and got no errors but still having problems printing/ returning any help would be great.
def disemvowel(word):
blank = ""
vowelslower = ["a", "e", "i", "o","u"]
vowelsupper = ["A", "E", "I", "O","U"]
for i in word:
if i not in vowelslower or vowelsupper:
blank += i
word = blank
return word
1 Answer
Kevin Faust
15,353 PointsHey Steve your problem lies here:
if i not in vowelslower or vowelsupper:
it should be
if i not in vowelslower and vowelsupper:
the reason we do 'and' is because we dont want the letter we are currently looping on to be a lowercase or uppercase vowel. in fact, you could just combine those 2 vowel lists into just 1 list. or another option is to call .lower() on the letter we are looping on and check if that is in our vowelslower, which would eliminate the need for vowelsupper
also a side note:
word = blank
return word
is not needed. you can just return the 'blank' variable directly
hope that helps