I'm just beginning with python and I have to define a function to check how many strings in a list have more than 2 characters or have their first and last characters same:
def match_ends(words):
count=0
for w in words:
if len(w)>=2:
count+=1
elif w[0]==w[-1]:
count+=1
return count
I get an error message saying:
elif w[0]==w[-1]:
IndexError: string index out of range
What does this mean and how do I correct it?