Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 287 Bytes

slicing_lvl_2.md

File metadata and controls

21 lines (17 loc) · 287 Bytes

Slicing - Level 2

What is the result of each of the following statements if x = 'abcdefgh'

  1. x[-1:-2]
  2. x[3:-1]
  3. x[::1]
  4. x[::3]
  5. x[1:2:3]
  6. x[::-1]
  7. x[1::-1]

Solution

  1. ''
  2. 'defg'
  3. 'abcdefgh'
  4. 'adg'
  5. 'b'
  6. 'hgfedcba'
  7. 'ba'