For loops

Usually for loops are used for range loops (list) , usually the syntax is this:

for iterating_var in sequence:
   statements(s)

The difference with the «with» loops is that you don’t have to have «true» or «false» variables because it is used for lists. Example:

for letter in 'Python':     
   print 'Current Letter :', letter

Resulting in:

Current Letter : P
Current Letter : y
Current Letter : t
Current Letter : h
Current Letter : o
Current Letter : n

 

Examples and more from: https://www.tutorialspoint.com/python/python_for_loop.htm

Deja un comentario