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.
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.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join