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 Disemvoweled

Is there a logic or flow diagram of this program?

I am very lost y the number of functions within functions and Kenneth does not show it or explain it (or I am too slow). Thanks!

1 Answer

Max Hirsh
Max Hirsh
16,773 Points

I could provide a written explanation/flowchart of how the program works. Basically:

  1. This program takes a list of names of US states.

  2. Then, the names are converted to lower case, which makes it easier to work with since we don't have to worry about identifying capital vs. lower case letters.

  3. There is a list of lowercase vowels, "aeiou". The list is moved through with a "for" loop. This means that for each vowel in the list: a. The program will keep "Try"ing to remove that vowel, one instance at a time from the list of state names, while "True". The "While True" part just keeps looping through infinitely many times until a "break" command happens. Then, when that vowel is no longer in the list, an error is raised, this causes python to: b. Run the "Except:" statement. In this case, the only command is "break", so python breaks out of the "While True" loop and then c. goes back to step a. for the next vowel in the list!

  4. After every vowel is removed, the empty list "Output" is appended with every state name separates by a " " (space). The "capitalize()" method is called on the state list first, so that the first letter of every word is capitalized.

  5. The variable "Output" is printed.

Let me know if this explanation helps! Also sorry you've gone so long without an answer to your question.