Download python eBook


As one of the most basic functions in programming, loops are an important piece to nearly every programming language. Loops enable developers to set certain portions of their code to repeat through a number of loops which are referred to as iterations. This topic covers using multiple types of loops and applications of loops in Python.


  • while <boolean expression>:
  • for <variable> in <iterable>:
  • for <variable> in range(<number>):
  • for <variable> in range(<start_number>, <end_number>):
  • for <variable> in range(<start_number>, <end_number>, <step_size>):
  • for i, <variable> in enumerate(<iterable>): # with index i
  • for <variable1>, <variable2> in zip(<iterable1>, <iterable2>):


boolean expressionexpression that can be evaluated in a boolean context, e.g. x < 10
variablevariable name for the current element from the iterable
iterableanything that implements iterations

Related Examples


1162 Contributors: 56
Saturday, July 22, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook