I am trying to convert a list with integers values in a list with strings
a=[[1, 2, 4, 3, 2, 1]]
And I would like to get something like that
b=[['1', '2', '4', '3', '2', '1']]
thanks a lot!
CodePudding user response:
Supposing you are talking about python, here is the solution:
b = [str(int) for int in a]
Notice that this will work if a is a list, from your question it seems that you are dealing with a list of list (given the double square brackets)
CodePudding user response:
Assuming Python, you may use a list comprehension:
a = [1, 2, 4, 3, 2, 1]
b = [str(x) for x in a]
print(b) # ['1', '2', '4', '3', '2', '1']
CodePudding user response:
You can use list comprehension:
a = [1, 2, 4, 3, 2, 1]
b = [str(i) for i in a]