Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.35 KB  |  hits: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to apply list methods on a slices in python
  2. a = [1,2,3,4,5]
  3. x = a[1:]
  4. x.insert(0,5)
  5.        
  6. x = a[1:].insert(0,5)
  7.        
  8. spacelist = [ alist[1:].extend(alist[:2].insert(0,1)) for i in range(0,len(alist))]
  9.        
  10. a = [1,2,3,4,5]
  11. x = (lambda x: x.insert(0,5) or x)(a)
  12.        
  13. x = [5] + a[1:]
  14.        
  15. spacelist = [alist[1:] + [1] + alist[:2] for i in range(len(alist))]