Ajout du tp sur python
This commit is contained in:
15
sisr2/sisr/35-python/occurence.py
Normal file
15
sisr2/sisr/35-python/occurence.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
chaine = str(input("saisir une chaine"))
|
||||
|
||||
tab = chaine.split(" ")
|
||||
|
||||
cptmot = {}
|
||||
for mot in tab:
|
||||
if mot in cptmot:
|
||||
cptmot[mot] += 1
|
||||
else:
|
||||
cptmot[mot] = 1
|
||||
|
||||
for mot in cptmot.keys():
|
||||
print("Mot: ",mot ," : ",cptmot[mot])
|
||||
Reference in New Issue
Block a user