我有两个列表,我正在尝试根据它们出现的次数创建多个数字副本。
numbers = [0, 1, 2]
amount = [1, 2, 3]
我试过了:
total = []
n = 0
for i in range(len(numbers)):
product = numbers[n] * amount[n]
n += 1
total.extend(product)
但我得到了错误:
TypeError: 'int' object is not iterable.
我的预期输出是:
total = [0, 1, 1, 2, 2, 2]