Learning list .pop () method, to realize the function: through a list of every element inside, and then delete the last element, and print the current list, as shown below:
Later want to use for loop iterates print, the results shown:
The for loop can not completely remove the elements of the list! Really I do not know what the reason is, in large Xiangqun God for advice.
One of the great God posted the link:
Ran and eggs, do not understand ah!
Another great God spoke:
The first guest takes guests [0], for one cycle after the last guests element is removed, a reduced number of elements in the original list. Second cycle time is reduced in value in a list of guests, while the second is taken from the guests guests [. 1], and so on, when guests [guest] values fail to bounce back to cycle.
Pretend to understand. . .
Finally, God put a big procedural code, very intuitive. . . However, I do not understand. . . I am helpless ah. . .
No need to get to the bottom of this problem, has a relationship with python design mechanism itself, if we must get to the bottom to see the python assembly code generated class. The conclusion is not to write a similar change in the outer layer of the inner code.
You can only write down, and so will we be able to see to understand. . .