script python
This commit is contained in:
17
sio2/sisr2/30-Python/Exo3
Normal file
17
sio2/sisr2/30-Python/Exo3
Normal 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])
|
Reference in New Issue
Block a user