From 9d9f0d4ee6314a12bf4083e91cc281c4d7876171 Mon Sep 17 00:00:00 2001 From: Elith Date: Sun, 16 Mar 2025 18:44:17 +0100 Subject: [PATCH] =?UTF-8?q?Fonction=20pour=20compter=20les=20actions=20man?= =?UTF-8?q?qu=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manque.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 manque.py diff --git a/manque.py b/manque.py new file mode 100644 index 0000000..e791571 --- /dev/null +++ b/manque.py @@ -0,0 +1,15 @@ +def manque(joueur): + """Calcule le nombre d'actions manquées par un joueur.""" + echecs = 0 + + with open("stats.txt", "r") as fichier: + for ligne in fichier: + data = ligne.split() + if data[0] == joueur and ("tir-manque" in data[1] or "lancer-rat" in data[1] or "perteBalle" in data[1]): + echecs += 1 + + return echecs + +# Test +if __name__ == "__main__": + print(manque("J1"))