t519.py 781 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. l = ['h','e','l','l','o']
  2. print l.index('l')
  3. print l.index('l', 2)
  4. print l.index('l', 3)
  5. print l.index('l', 2, 3)
  6. print l.index('l', 3, 4)
  7. print l.index('l', 2, -1)
  8. print l.index('l', 2, -2)
  9. print l.index('l', 3, -1)
  10. try:
  11. print l.index('l', 4)
  12. except ValueError as e:
  13. print e
  14. try:
  15. print l.index('l', -1)
  16. except ValueError as e:
  17. print e
  18. try:
  19. print l.index('l', 2, 2)
  20. except ValueError as e:
  21. print e
  22. try:
  23. print l.index('l', 3, 2)
  24. except ValueError as e:
  25. print e
  26. try:
  27. print l.index('l', 3, -2)
  28. except ValueError as e:
  29. print e
  30. try:
  31. print l.index('l', 3, 0)
  32. except ValueError as e:
  33. print e
  34. try:
  35. print l.index('l', 4.3)
  36. except TypeError as e:
  37. print e
  38. try:
  39. print l.index('l', 3, 0.6)
  40. except TypeError as e:
  41. print e