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 in a list of strings.
Python Code :
nums_list = [1,2,3,4] nums_tuple = (0, 1, 2, 3) print("Original list and tuple:") print(nums_list) print(nums_tuple) result_list = list(map(str,nums_list)) result_tuple = tuple(map(str,nums_tuple)) print("\nList of strings:") print(result_list) print("\nTuple of strings:") print(result_tuple)
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.
Python: Tips of the Day
Clamps num within the inclusive range specified by the boundary values x and y:
def tips_clamp_num(num,x,y): return max(min(num, max(x, y)), min(x, y)) print(tips_clamp_num(2, 4, 6)) print(tips_clamp_num(1, -1, -6))
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework