script python

This commit is contained in:
Johan Largy
2022-09-29 08:55:42 +02:00
parent 249b8ed74f
commit 4850b95120
2 changed files with 40 additions and 0 deletions

17
sio2/sisr2/30-Python/Exo3 Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/python3
phrase=str(input("phrase :"))
#eclatage de la chaine de caractere en tableau avec séparateur espace
tabmots= phrase.split(" ")
cptmots={}
for mot in tabmots:
if not mot in cptmots:
cptmots[mot]=1
else:
cptmots[mot]=cptmots[mot] +1
#affichage des occurences
for mot in cptmots.keys():
print(mot, ":",cptmots[mot])