# 将0-9的列表生成一个新列表,新列表每个元素都在原列表基础上+1并平方
newlist1 = [(i+1)**2 for i in range(10)]
print(newlist1)
print(type(newlist1))
# 生成10个0的列表
newlist2 = [0 for _ in range(10)] # _ 表示不引用
print(newlist2)
# 生成10个[0]的嵌套列表
newlist3 = [[0] for _ in range(10)]
print(newlist3)
# 求偶数
newlist4 = [i for i in range(20) if i % 2 == 0]
print(newlist4)
# 既能被2整出,又能被3整除
newlist5 = [i for i in range(10) if i % 2 == 0 and i % 3 == 0]
print(newlist5)
# 能被2整出,或能被3整除
newlist6 = [i for i in range(10) if i % 2 == 0 or i % 3 == 0]
print(newlist6)
newlist7 = [(x, y) for x in 'abcde' for y in range(3)]
print(newlist7)
newlist8 = [(x, y) for x in range(7) if x > 4 for y in range(20, 25) if y > 23]
# newlist8 = [(x, y) for x in range(7) for y in range(20, 25) if x > 4 and y > 23]
print(newlist8)