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