Exercice36
Write a program in Python to delete multiple spaces in a string
Solution:
# Example of strings containing multiple spaces
s = " Python is object oriented a programming language"
# transform the string s to a python list
L = s.split()
#define an empty string s2
s2 = ""
# reconvert the list L in a chain by browsing the elements of the list.
for element in L:
s2 = s2 + element + " "
# The chain without multiple space
print(s2)
Younes Derfoufi
my-courses.net
my-courses.net