python 判断列表字符串元素首尾字符是否相同

def match_words(words):  
  ctr = 0  
  
  for word in words:  
    if len(word) > 1 and word[0] == word[-1]:  
      ctr += 1  
  return ctr  
  
print(match_words(['abc', 'xyz', 'aba', '122771']))

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/9967858.html