标签:lis err 列表 count 简单 int tom app print
#麻烦办法
new_lst = []
for i in range(10):
new_lst.append(i**2)
print(new_lst)
#简单办法
print([i**2 for i in range(10)])
# 小题下面列表中取余
list_a = [1,2,3,-5,20,-7]
print([i%2 for i in list_a])
# 30以内所有能被3整除的数
print([won for won in range(30) if won%3 == 0])
# 题目
names = [[‘Tom‘, ‘Billy‘, ‘Jefferson‘, ‘Andrew‘, ‘Wesley‘, ‘Steven‘, ‘Joe‘],
[‘Alice‘, ‘Jill‘, ‘Ana‘, ‘Wendy‘, ‘Jennifer‘, ‘Sherry‘, ‘Eva‘]]
print([i for name_list in names for i in name_list if i.count(‘e‘) == 2])
标签:lis err 列表 count 简单 int tom app print
原文地址:https://www.cnblogs.com/liwei-python-21/p/8977174.html