Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
state_names = ["Alabama","California","Oklahoma","Florida] vowels = list('aeiou') # vowels will return ["a","e","i","o","u"] output = 
for state in state_names:
state_list = list(state.lower()) #what value sate_list will return
for vowel in vowels:
while True: try: state_list.remove(vowel) except: break output.append('',join(state_list).capitalize()) print(output)
Can anybody tell me why do we have to join the state_list in the end? output.append('',join(state_list).capitalize())
I think it's just how you might want it to look. A list printed looks like this:
state_names = ["Alabama","California","Oklahoma","Florida] # .join() turns it into a string, kinda looks nicer for reading. Although there are # times you might need data to be either a string or a list to do certain things to # it. But I don't think that is happening here. " ".join(state_names) 'Alabama California Oklahoma Florida'