do_slice.py 362 B

12345678910111213141516
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']
  4. print('L[0:3] =', L[0:3])
  5. print('L[:3] =', L[:3])
  6. print('L[1:3] =', L[1:3])
  7. print('L[-2:] =', L[-2:])
  8. R = list(range(100))
  9. print('R[:10] =', R[:10])
  10. print('R[-10:] =', R[-10:])
  11. print('R[10:20] =', R[10:20])
  12. print('R[:10:2] =', R[:10:2])
  13. print('R[::5] =', R[::5])