fork download
  1. str = 'the little dinosaur'
  2. # format: string_name[start_pos_incl:stop_pos_excl]
  3. # zero-based index
  4. # the little...
  5. # 0123456789...
  6. print str[4:]
  7. # >>> little dinosaur
  8. print str[4:10]
  9. # >>> little
  10. # negative index:
  11. # count from the end of str, with -1 being the last position
  12. print str[:-4]
  13. # >>> the little dino
  14. print str[-4:]
  15. # >>> saur
Success #stdin #stdout 0.02s 4676KB
stdin
Standard input is empty
stdout
little dinosaur
little
the little dino
saur