liudaocen 发表于 2021-2-7 20:31:42

python零基础第12讲课后习题第5题

求助鱼油:

>>> list1 = [(x, y) for x in range(10) for y in range(10) if x%2==0 if y%2!=0]

为什么不能用
>>> for y in range(1,10,2):
                for x in range(0,10,2):
                        list1.append((x,y))
                       
我觉得同样是求出偶数x和奇数y,和甲鱼不同的是,我没有if,但是运行后显示很多重复的数据。


甲鱼的答案:
<<<list1 = []
for x in range(10):
    for y in range(10):
      if x%2 == 0:
            if y%2 != 0:
                list1.append((x, y))

昨非 发表于 2021-2-7 20:42:18

list1=[]
for x in range(0,10,2): #x,y对应的两层循环换个位置就好了啊
    for y in range(1,10,2):
      list1.append((x,y))
print(list1)

list2 = [(x, y) for x in range(10) for y in range(10) if x%2==0 if y%2!=0]
print(list2)

两种方法的测试结果是相同的,如下:(并没有重复数据啊)
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9)]

liudaocen 发表于 2021-2-7 20:47:12

昨非 发表于 2021-2-7 20:42
两种方法的测试结果是相同的,如下:(并没有重复数据啊)

这是我的运行结果{:10_266:}:


[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9)]
[(0, 1), (0, 3), (0, 5), (0, 7), (0, 9), (2, 1), (2, 3), (2, 5), (2, 7), (2, 9), (4, 1), (4, 3), (4, 5), (4, 7), (4, 9), (6, 1), (6, 3), (6, 5), (6, 7), (6, 9), (8, 1), (8, 3), (8, 5), (8, 7), (8, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (1, 9), (3, 9), (5, 9), (7, 9), (9, 9), (0, 1), (2, 1), (4, 1), (6, 1), (8, 1), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 5), (2, 5), (4, 5), (6, 5), (8, 5), (0, 7), (2, 7), (4, 7), (6, 7), (8, 7), (0, 9), (2, 9), (4, 9), (6, 9), (8, 9)]





昨非 发表于 2021-2-7 20:50:23

liudaocen 发表于 2021-2-7 20:47
这是我的运行结果:




你把我的代码复制过去

liudaocen 发表于 2021-2-7 20:50:42

昨非 发表于 2021-2-7 20:42
两种方法的测试结果是相同的,如下:(并没有重复数据啊)

C:\Users\liudaocen1\Desktop

liudaocen 发表于 2021-2-7 20:54:44

昨非 发表于 2021-2-7 20:50
你把我的代码复制过去

确实{:10_282:}
在idle里,print(list1)的话是正确的,但是输入list1显示的结果就是那些乱糟糟的数组了。我一直没打印所以以为自己做错了哈哈哈

昨非 发表于 2021-2-7 20:56:09

liudaocen 发表于 2021-2-7 20:54
确实
在idle里,print(list1)的话是正确的,但是输入list1显示的结果就是那些乱糟糟的数组 ...

所以还有问题吗{:10_304:}

liudaocen 发表于 2021-2-7 20:59:36

昨非 发表于 2021-2-7 20:56
所以还有问题吗

没啦没啦,谢谢您!

昨非 发表于 2021-2-7 21:01:01

liudaocen 发表于 2021-2-7 20:59
没啦没啦,谢谢您!

请把帖子类型修改为【求助帖】(帖子左下角重新编辑)
方便设置最佳答案
(我能得到系统奖励的)

昨非 发表于 2021-2-7 21:17:28

@不二如是 @小甲鱼 麻烦管理分类下帖子顺带设个最佳{:10_266:}
页: [1]
查看完整版本: python零基础第12讲课后习题第5题