我正在尝试编写一个函数,该函数接受例如[1,2,3]的输入并返回[ 1,1,2,2,3,3]但我得到一个错误编写一个函数,它将一个列表作为参数,并返回一个列表,该列表重复列表中的元素
这里是代码我现在
def problem3(aList):
list1= []
newList1= []
for i in range (len(aList)):
list1.append(aList[i])
for i in range (0, len(list1)):
newList1= aList + list1[i]
这是错误
"Traceback (most recent call last): Python Shell, prompt 2, line 1 File "h:\TowlertonEvanDA7.py", line 34, in newList1= aList + list1[i] builtins.TypeError: can only concatenate list (not "int") to list"