[enter image description here][1]
[1]: https://i.stack.imgur.com/54Ut8.png***This is " IndexError: string index out of range" typenter code heree or error***
Bellow the code:
def first_and_last(message):
if message[0] == message[-1] or message is None:
return True
return False
print(first_and_last("else"))
print(first_and_last("tree"))
print(first_and_last(""))
Bellow the Output of the above Code
True
False
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-9-026229c3b5af> in <module>
6 print(first_and_last("else"))
7 print(first_and_last("tree"))
----> 8 print(first_and_last(""))
<ipython-input-9-026229c3b5af> in first_and_last(message)
1 def first_and_last(message):
----> 2 if message[0] == message[-1] or message is None:
3 return True
4 return False
5
IndexError: string index out of range
Aucun commentaire:
Enregistrer un commentaire