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.

Python Python Collections (Retired) Lists Redux Lists overview

About For...loop

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:                # for vowel 
      while True:
          try:
              state_list.remove(vowel) 
          except:
              break
  output.append('',join(state_list).capitalize())
print(output)

There are two for-loops, what is the sequence of doing the loop?

Xi,

I edited your question to make the code more legible, but made no changes. I'm sorry, I don't understand your question. Can you explain more?

1 Answer

I meant for..loop. The order is to finish the first loop to iterate every item in state_list until its done and go to the second for..loop or read one item in state_list and going to the second for..loop?