Exercice 64
Écrire un programme python comme une fonction qui prend comme paramètre une chaîne s et qui retourne
une autre chaîne obtenue à partir de s en supprimant les espaces au début de la chaîne s et les espaces à la fin de la chaîne s sans utiliser le lstrip () ni aucune méthode prédéfinie.
Exemple si s = " Bonjour " , la fonction renvoie la chaîne
"Bonjour"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# coding: utf-8 def removeSpace(s): n = len(s) # initialisation du nombre d'espace à la fin de la chaine s j = 0 while(s[n-1-j]) == " ": j = j + 1 s = s[:n-j] # initialisation du nombre d'espace au début de la chaine s i = 0 while s[i] == " ": i = i + 1 s = s[i:] return s # Exemple s = " Hello World " print("'",s,"'") # affiche : ' Hello World ' print("'",removeSpace(s),"'") # affiche :'Hello World' |
Younes Derfoufi
CRMEF OUJDA
excellent points altogether, you just won a emblem new reader.
What could you suggest in regards to your post that you just made a few days ago?
Any sure?
Here is my website … ace333 download ios
Greetings from Florida! I’m bored to tears at work so I decided to browse your site on my iphone
during lunch break. I really like the knowledge you provide here and
can’t wait to take a look when I get home. I’m amazed at
how fast your blog loaded on my phone .. I’m
not even using WIFI, just 3G .. Anyhow, awesome site!
Here is my web page … joker123 apk new version
I will right away grab your rss feed as I can’t in finding your email subscription hyperlink or newsletter service.
Do you have any? Kindly let me understand in order that I could subscribe.
Thanks.
Amazing issues here. I’m very glad to see your post.
Thanks a lot and I am having a look forward to touch you. Will you kindly drop me a e-mail?
I read this article fully concerning the difference of latest and previous technologies, it’s remarkable article.
Hi there to every single one, it’s truly a nice for me
to pay a visit this web page, it consists of precious Information.