Python: Remove additional spaces in a given list
Remove Extra Spaces from List
Write a Python program to remove additional spaces from a given list.
Sample Solution:
Python Code:
Sample Output:
Original list: ['abc ', ' ', ' ', 'sdfds ', ' ', ' ', 'sdfds ', 'huy'] Remove additional spaces from the said list: ['abc', '', '', 'sdfds', '', '', 'sdfds', 'huy']
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to trim whitespace from the beginning and end of each string in a list.
- Write a Python program to remove only the leading spaces from each element in a list of strings.
- Write a Python program to remove extra spaces from a list and join the non-empty strings into a single sentence.
- Write a Python program to replace multiple consecutive spaces within each string in a list with a single space.
Python Code Editor:
Previous: Write a Python program to find the indices of elements of a given list, greater than a specified value.
Next: Write a Python program to find the common tuples between two given lists.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.