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.
General technique and a program that won't run.
Hey everyone! My first question is could anyone guess some reasons that my program simply won't run? When I try to run it in the shell it acts as if it is running but no list of vowel free states appears. When I tinker with the above script and re-run it I get error messages I expect, so maybe it is reading it. Could it be that my last two lines-- "output.append....." and "print (output)" aren't arranged correctly? As i understood it they could run outside the while loop, but I tried putting them in it just in case.
Something related that I was wondering about was, how might I understand Pythons treatment of each of the state names in the original name list? I see the program iterates through the vowel list and removes them from the state_list, but why doesn't it need a separate command to iterate through the entire state_list since it's made of many items?
My apologies if any of that is convoluted. This is still foreign to me. Thanks for any insight!
Steven Parker218,635 Points
As the others mentioned, you should post the code you would like specific help with.
But for your other question, the program does not need a loop to iterate through state_list because the remove method will take away the vowels no matter where they are in the list. In a sense, remove is the command you are expecting.
You should probably put some quotes or something around your Strings in your State_names list. Maybe do the same with your vowels variable.
I tweaked your code to make it run, I didn't fix any logic errors if any, but here is the code that runs:
State_names = ['California', 'Florida', 'Oklahoma'] vowels = ['a','e','i','o','u'] output =  for state in State_names: State_list = list(state.lower()) for vowel in vowels: while True: try: State_list.remove(vowel) except: break output.append(''.join(State_list).capitalize()) print(output)