counter = 0 words = ['abc', 'xyz', 'aba', '1221'] for word in words: if word[0] == word[-1]: counter += 1 print(counter)