For loop syntax structure columns such as sequences or iterators as their arguments each iteration of one element is the same as a while loop, with support for BREAK,CONTINUE,ELSE statements in general, the number of loops is unknown in the while loop, and the number of cycles is known to use the for
for inch ' ABCD ' :... Print ch ... abcd for inch ' ANCD ' :... Print Ch,... a n c d
The print statement adds a newline character to each line by default, as long as you add a comma after the print statement, you do not wrap.
The range function for loop is often used with the range function to provide a loop condition with the full syntax of the range function: Range (start,end,step=1)
>>> Range (1,4) [1, 2, 3]>>> range (41, 2, 3]>>> Range ( 1,4,2) [1, 3]
Rage generates a list of print list subscripts and values
alist=[' Tom ', ' Bob ', ' vs ', ' cm ', '
for inch Range (len (alist)): ... . Print " %s:%s " % (I,alist[i]) ... 0:tom1: Bob2: vs3:cm
Python-for Loop and Range () built-in functions