Python primary loop 6 (b)

First, review

1 for loop

for looper in [1, 2, 3, 4]:
    print("hello")

1) the start of each cycle, will be followed by the sequence number in the list assigned to the looper, a looper is a first, second 2, third 3, fourth 4

2) each assigned a value, it will work under all instruction blocks executed again, this is also called the loop instruction block

3) After each execution, variable looper will be assigned a value on the next list until Fu have been exhausted

2 break out of

3 range () function

A list 1) Range (1, 5) represented by [1, 2, 3, 4], 5 represents the right border is not a specific value

2) We usually write Range Range (0, 4), showing a list of [0, 1, 2, 3], which is typically a computer representation of numbers, starting from this particular number 0, to the end of the boundary 4 (not including border 4) a total of 4 numbers

3) range Starter, range (4) means that the range (0, 4)

4 String Format: placeholder

print("{},{}".format(1, 2))

Guess you like

Origin www.cnblogs.com/luhouxiang/p/11516094.html