I am trying to write a function that takes an array, converts it to a string, then appends it together.
Ex. [1,2,3,4,5,6]
would return '123456'
.
Here is the code that I tried already, but it gives me the error "list indices must be integers, not str"
a = [1,2,3,4,5,6,7,8,9,10]
def add_it_up(a,b):
return a+b
def to_str(a):
for i in a:
a[i] = str(a[i])
reduce(add_it_up, a)
a = [1,2,3,4,5,6,7,8,9,10]
def to_str(a):
''.join(map(str, l))
return a
what is wrong with the above code? it is just returning the original a value.