python: convert each element to string in a list, without using for loop

Viewed 2462

for solving above problem I normally use for loop like that:

list1 = ['1', '2', 3,32423,5.76, "afef"]
list2 = []
for ele in list1:
  list2.append(str(ele))

does python has some build in function for solving that problem?

1 Answers

You can use the built-in function map like the following:

list1 = ['1', '2', 3, 32423, 5.76, "afef"]
list2 = list(map(str, list1))
Related