Control Flow: The for
Loops Summary
Summary
Repeating Instructions with for
loops
for _ in range(4):
can be used to repeat the same sequence of instructions as much as four times_
is the loop variable and you can use any variable name such as index, count, my_loop_variable, etcrange(4)
function.range(10)
returns the integer numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9range(5, 10)
returns the integer numbers 5, 6, 7, 8, 9range(10, 2)
returns nothing as the second argument should be larger to generate a sequencerange(5, 10, 2)
returns the integer numbers 5, 7, 9Block scoping, variable shadowing, and using global
keyword for accessing global variables from functions.
break
and continue
for-else
structure
Nested for
loops
Random Numbers
Declaring and using tuples and lists.
is
operator for checking object/instance equality.