码住!Python 列表玩减法,同长同型是关键
list1 = [3, 6, 9]list2 = [1, 3, 8]result = for i, j in zip(list1,list2): result.append(i - j)print(result) # 输出:[2, 3, 1]
list1 = [3, 6, 9]list2 = [1, 3, 8]result = for i, j in zip(list1,list2): result.append(i - j)print(result) # 输出:[2, 3, 1]