def is_endwith_s(n): """ 判断是否以s结尾 :param n: str or int :return: bool """ return str(n).endswith('s') # 待判断的可迭代对象 lis = ['ss', 'ss', 'ss', 'aa', 'aa', 'ss', 'ss', 'ss', 'ss', '22'] lis_s = [word if is_endwith_s(word) else '666' for word in lis] print(lis_s) # ['ss', 'ss', 'ss', '666', '666', 'ss', 'ss', 'ss', 'ss', '666']