Python: Concatenate all elements in a list into a string and return it
Python Basic: Exercise-27 with Solution
Write a Python program to concatenate all elements in a list into a string and return it.
def concatenate_list_data(list): result= '' for element in list: result += str(element) return result print(concatenate_list_data([1, 5, 12, 2]))
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to create a histogram from a given list of integers.
Next: Write a Python program to print out all even numbers from a given numbers list in the same order and stop the printing if any numbers that come after 237 in the sequence.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
>>> m = [x ** 2 for x in range(5)] >>> m [0, 1, 4, 9, 16]
- New Content published on w3resource:
- 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