pythonflowchart

Flowchart Iterating through List


Let say I have a list l

l = ['a', 'b', 'c']

To iterate through the list,

for i in l:
    # <some function>

My problem is how should I represet it in a flowchart? Should I use i as index? Thanks in advance.


Solution

  • Flowcharts are rather miserable for loops

    Here is the usual way to do it (from http://etutorials.org/Programming/visual-c-sharp/Part+I+Introducing+Microsoft+Visual+C+.NET/Chapter+5+Flow+of+Control/Building+Loops+Using+Iteration+Statements/)

    enter image description here

    Flowcharts work best for branching workflows with lots of "ifs"

    As you progress, you are getting into smaller and smaller subsets of the overall chart.

    They can work for looping, of the type of while do or do while, because these inherently tell you to jump back to a point (or skip over a block).

    But for looping controlled by a variable, it's ugly, I'm afraid.

    In your specific case, you could use these terms:

    Initialization:

    Conditional expression

    Controlled statement

    Iteration statement