python: how to use the for statement

The syntax of the for loop is:

for i in range(n): #Assign a value from the data type to i 
    print (i) #Print i

E.g:

# for 
for i in range (1,6,2): #every 2 digits from the beginning to the sixth 
    print (i) 
#the result is 1,3,5 # ---------- -------------------------------------- 
s = [ " man " , " woman " , " girl " , " boy " , " sister " ]
 for i in s: #Each element in the list s is given to i print (i)
 # ------------------- ------------------------------ for i
    
in range(5 ):
     print (i) #The result is: 0,1,2,3,4

For loop example: The numbers 0, 1, 2 form a hundred digit, and the numbers do not repeat!

#for
for i in range(0,3):
    for j in range(0,3):
        for k in range(0,3):
            if (i != 0) and (i != j) and (i != k) and (j != k):
                print (i,j,k)

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325817691&siteId=291194637