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!
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 trial
Adam Ryde5,222 Points
here is my code.... its late, i have been at work since 5am and i just cannot get my brain to function around this. my way of thinking was, if i put the upper and lower case values of vowels into lists of their own, i could then use those lists to find the vowels and delete them?
i am guessing i was wrong.
def disemvowel(word): vowels_lower = ["a", "e", "i", "o", "u"] vowels_upper = ["A", "E", "I", "O", "U"]
if vowels_lower in word: del vowels_lower elif vowels_upper in word: del vowels_upper return word
def disemvowel(word): vowels_lower = ["a", "e", "i", "o", "u"] vowels_upper = ["A", "E", "I", "O", "U"] if vowels_lower in word: del vowels_lower elif vowels_upper in word: del vowels_upper return word
james southFront End Web Development Techdegree Graduate 33,271 Points
this throws an error because you are asking if a list is in a string. there's a method in python (lower) that you can call on a string like myString.lower() that will return a lower-case version of myString. you can store that in a variable, cast it to a list and loop through it, removing the vowels from a copy of the list (you must avoid looping through a list that you are simultaneously modifying), or just append the consonants to a new string. either way you should end up with the correctly disemvoweled word.