Last active
December 19, 2017 00:28
-
-
Save BlogBlocks/005e2b61a91bfb3e255cf2633155d3fa to your computer and use it in GitHub Desktop.
Using a list from first to last entry or last to first by removing items on the list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Demonstration: | |
| How to remove elements one at a time from a list. | |
| front to rear, then rear to front | |
| """ | |
| from time import sleep | |
| ID = [750,771,772,1000,1077,1099,1110,1277,1499, 2000, 20050, 20167] | |
| count = 0 | |
| inc = len(ID) | |
| while count < inc: | |
| for start in ID: | |
| sleep(.1) | |
| print start, | |
| del ID[-1];print "\n" | |
| count =count+1 | |
| count = count +1 | |
| ID = [750,771,772,1000,1077,1099,1110,1277,1499, 2000, 20050, 20167] | |
| count = 0 | |
| inc = len(ID) | |
| while count < inc: | |
| for start in ID: | |
| sleep(.1) | |
| print start, | |
| del ID[-inc+count] | |
| print "\n" | |
| count =count+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment