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 for word in lis if is_endwith_s(word)] print(lis_s) # ['ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss']