5.B. Chaîne de caractères : remplacer dans une sous-partie#

Consignes#

Étant donnée une chaîne de caractères entrée au clavier contenant au moins deux fois la lettre h, remplacer toutes les occurrences de h par H, sauf la première et la dernière.

Exemple d’entrée#

In the hole in the ground there lived a hobbit

Exemple de sortie#

In the Hole in tHe ground tHere lived a hobbit

Aide#

https://docs.python.org/fr/3.6/library/stdtypes.html#common-sequence-operations

https://docs.python.org/fr/3.6/library/stdtypes.html#str.find

https://docs.python.org/fr/3.6/library/stdtypes.html#str.rfind

https://docs.python.org/fr/3.6/library/stdtypes.html#str.replace

Codez votre solution ci-dessous#

[splashscreen] enabled = false # Lire une chaîne de caractères au clavier : # s = input() # Afficher une chaîne de caractères : # print(s) from js import document as _DOC def clear_term(): ter = _DOC.getElementById("my-terminal").firstChild ter.innerHTML = ''