1 changed files with 16 additions and 0 deletions
@ -0,0 +1,16 @@ |
|||
def reussite(joueur, action): |
|||
tentatives = 0 |
|||
reussites = 0 |
|||
with open('stats.txt', 'r') as f: |
|||
for ligne in f: |
|||
mots = ligne.split() |
|||
if mots[0] == joueur and mots[1] == action: |
|||
tentatives += 1 |
|||
if mots[2] == 'reussi' or mots[2] == 'reussie': |
|||
reussites += 1 |
|||
return (tentatives, reussites) |
|||
|
|||
# Exemple |
|||
joueur = 'J1' |
|||
action = 'tir' |
|||
print(reussite(joueur, action)) |
Loading…
Reference in new issue