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 trial

Python Python Collections (Retired) Lists Redux Lists overview

"".join()

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())

1 Answer

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'