python circulation and level 5 is determined for ... in ... and while loops integer range list

 

 

 for ... in ... can identify the list of dictionary string range () function range () does not recognize the integer floating point

 

range: a list of integers

range (x) function, can generate a sequence of integers from 0 to x-1 of

Using the range (a, b) function, you can generate a sequence of integers {} takes the head of the tail is not taken.

 

When you want a piece of code is fixed repeated n times, it can be used directly for i in range (n), the code is repeated n times.

range (0,10,3) means: a number from 0 to 9 (not take take the first tail), the interval number is 3

 

range (a, b, c) a list of integers, is not considered a tail head B, interval c

 

 

 

for ... in ... the dictionary

for ... in ... the print key

 

Print value for ... in ...

 

 

while loop

 

 

 

 

After indentation [while] is the clause will be executed cyclically

 

 

 

 

Note that some single quotes

 

 

 

 

Guess you like

Origin www.cnblogs.com/cloud7777/p/11565758.html