list_pop.py 347 B

1234567891011121314151617
  1. # list poppin'
  2. a = [1, 2, 3]
  3. print(a.pop())
  4. print(a.pop())
  5. print(a.pop())
  6. try:
  7. print(a.pop())
  8. except IndexError:
  9. print("IndexError raised")
  10. else:
  11. raise AssertionError("No IndexError raised")
  12. # popping such that list storage shrinks (tests implementation detail of uPy)
  13. l = list(range(20))
  14. for i in range(len(l)):
  15. l.pop()
  16. print(l)