现有如下列表推导式:
list1 =[(x,y) for x in range(10) for y in range(10) if x%2 == 0 if y%2 != 0]
请将列表推导式还原,结果如下:
#定义一个列表
list1=[] for x in range(10):
#遍历取x for y in range(10):
#遍历取y if x%2==0: if y%2!= 0: list1.append((x,y)) print(list1)
又或者这样写:
list1=[] for x in range(10): for y in range(10): if x%2==0 and y%2!= 0: list1.append((x,y)) print(list1)