For

--Originally published at 101 For Tec

For

The flowchart of a for is like it follows:

for_1.PNG

This is the basic structure:

for_0.PNG

val is a certain value or ‘conditional’

Here is one example

for_2.PNG

for_3.PNG

Important information about for´s:

  • The for statement in Python has the ability to iterate over the items of any sequence, such as a list or a string.
  • If a sequence contains an expression list, it is evaluated first. Then, the first item in the sequence is assigned to the iterating variable iterating_var. Next, the statements block is executed. Each item in the list is assigned to iterating_var, and the statement(s) block is executed until the entire sequence is exhausted.

References:

http://www.programiz.com/python-programming

http://www.tutorialspoint.com/python3/