Python Program to convert List of Integer to List of String
Given a List of Integers. The task is to convert them to List of Strings. Examples:
Input: [1, 12, 15, 21, 131] Output: ['1', '12', '15', '21', '131'] Input: [0, 1, 11, 15, 58] Output: ['0', '1', '11', '15', '58']
Method 1: Using map()
Python3
# Python code to convert list of# string into sorted list of integer # List initializationlist_int = [1, 12, 15, 21, 131] # mappinglist_string = map(str, list_int) # Printing sorted list of integersprint(list(list_string)) |
Output:
['1', '12', '15', '21', '131']
Example 2: Using list comprehension
Python3
# Python code to convert list of # string into sorted list of integer # List initializationlist_string = [1, 12, 15, 21, 131] # Using list comprehensionoutput = [str(x) for x in list_string] # Printing outputprint(output) |
Output:
['1', '12', '15', '21', '131']
Method 3: Using iteration
Python3
# Python code to convert list of# string into sorted list of integer # List initializationlist_string = [1, 12, 15, 21, 131] list_int = []# using iteration and sorted()for i in list_string: list_int.append(i) # printing outputprint(list_int) |
Output:
['1', '12', '15', '21', '131']
Method: Using enumerate function
Python3
lst = [1, 12, 15, 21, 131];l=[]for i,a in enumerate(lst): l.append(str(a))print(l) |
Output
['1', '12', '15', '21', '131']



Please Login to comment...