Python: Convert a list of integers, tuple of integers in a list of strings

Python map: Exercise-8 with Solution

Write a Python program to convert a given list of integers and a tuple of integers into a list of strings.

Sample Solution:

Python Code :

nums_list = [1,2,3,4]
nums_tuple = (0, 1, 2, 3) 
print("Original list and tuple:")
result_list = list(map(str,nums_list))
result_tuple = tuple(map(str,nums_tuple))
print("\nList of strings:")
print("\nTuple of strings:")

Sample Output:

Original list and tuple:
[1, 2, 3, 4]
(0, 1, 2, 3)

List of strings:
['1', '2', '3', '4']

Tuple of strings:
('0', '1', '2', '3')

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to add two given lists and find the difference between lists. Use map() function.
Next: Write a Python program to create a new list taking specific elements from a tuple and convert a string value to integer.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.