Solution Exercice 36: supprimer les espaces multiple d’un texte en Python
Publié le29 septembre 2019
Ecrire un programme en Python permettant de supprimer les espaces multiples dans une chaine s.
# -*- coding: utf-8 -*-
s = "Exemple de texte avec des espaces multiple"
# Transformer le texte en une liste
L = s.split()
# initialiser le texte sans espace à un texte vide
texteSansEspace = ""
# Reconstruire le texte en parcourant les éléments de la liste
for x in L:
texteSansEspace = texteSansEspace + x + " "
Privacy & Cookies Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.