I put my coding in IDLE and got error message
TypeError: can only concatenate list (not "int") to list.
Why the python doesn't accept index in values[index]
as an int
?
What should I do with this problem?
def repeat_elem (values, index, num_times):
# this function returns a new list in which the element of 'values'
# at position 'index' has been repeated 'num_times' times
return values[:index] + values[index]*(num_times - 1) + values[index+1:]