Reputation: 557
I'm knocking my head against a wall regarding adding quotes to a list of numbers.
How do I add single quotes to this list of numbers?
num = [1, 2, 3, 4]
Upvotes: 2
Views: 135
Reputation: 27
Try this solution:
x = [1,2,3,4]
x = map(lambda x: str(x), x)x = list(x)
print(x)
str(x)
Upvotes: 0
Reputation: 111
num= list(map(str, num))
print(num)
#output
['1', '2', '3', '4']
Upvotes: 2
Reputation: 2710
Try this:
num = [1, 2, 3, 4]
new_list = [str(i) for i in num]
#output
print(new_list)
['1', '2', '3', '4']
Upvotes: 4
Reputation: 7224
here you go: :-)
In [1335]: str(num)
Out[1335]: '[1, 2, 3, 4]'
Upvotes: 1