You can rewrite the function like below:
def concatenate_list_data(list):
result=""
for element in list:
result += str(element)
return result
my_result = concatenate_list_data([1, 5, 12, 2]) # leads to 15122
Another approach to the same can be using a list comprehension:
to_join = [1, 5, 12, 2]
output="".join([str(i) for i in to_join])
1
solved TypeError “int” in Python