1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- l = ['h','e','l','l','o']
- print l.index('l')
- print l.index('l', 2)
- print l.index('l', 3)
- print l.index('l', 2, 3)
- print l.index('l', 3, 4)
- print l.index('l', 2, -1)
- print l.index('l', 2, -2)
- print l.index('l', 3, -1)
- try:
- print l.index('l', 4)
- except ValueError as e:
- print e
- try:
- print l.index('l', -1)
- except ValueError as e:
- print e
- try:
- print l.index('l', 2, 2)
- except ValueError as e:
- print e
- try:
- print l.index('l', 3, 2)
- except ValueError as e:
- print e
- try:
- print l.index('l', 3, -2)
- except ValueError as e:
- print e
- try:
- print l.index('l', 3, 0)
- except ValueError as e:
- print e
- try:
- print l.index('l', 4.3)
- except TypeError as e:
- print e
- try:
- print l.index('l', 3, 0.6)
- except TypeError as e:
- print e
|