Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 19, 2017 00:28
Show Gist options
  • Select an option

  • Save BlogBlocks/005e2b61a91bfb3e255cf2633155d3fa to your computer and use it in GitHub Desktop.

Select an option

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
"""
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