From 764de673e12b88c9fb9ff530d652875b834e4a1a Mon Sep 17 00:00:00 2001 From: Zeftax Date: Mon, 21 Oct 2019 16:27:23 +0200 Subject: [PATCH] fixed bug, where your answer was regarded as wrong when it contained uppercase letter in the .tst file --- tests/PSP.tst | 19 +++++++++++++++++++ vyzkousejme.pyw | 19 ++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 tests/PSP.tst diff --git a/tests/PSP.tst b/tests/PSP.tst new file mode 100644 index 0000000..fa1cfab --- /dev/null +++ b/tests/PSP.tst @@ -0,0 +1,19 @@ +0.0 +H/Vodík +He/Helium +Li/Lithium +Be/Beryllium +B/Bor +C/Uhlík +N/Dusík +O/Kyslík +F/Fluor +Ne/Neon +Na/Sodík +Mg/Hořčík +Al/Hliník +Si/Křemík +P/Fosfor +S/Síra +Cl/Chlor +Ar/Argon diff --git a/vyzkousejme.pyw b/vyzkousejme.pyw index 4c436fd..2d082ee 100644 --- a/vyzkousejme.pyw +++ b/vyzkousejme.pyw @@ -53,15 +53,16 @@ def on_closing(): #zobrazi se pri zavirani programu, pokud se uzivatel rozhodne def submitAnswer(uselessArgument): # precte pole pro zadani odpovedi, zhodnoti ji, a vhodnym zpusobem zmeni score a highscore global score - if answerEntry.get().lower() in test[1] [questionPlace]: - score += timeMultiplier - currentScore.set('Score: %s' % (score)) - else: - score = 0 - currentScore.set('Score: %s' % (score)) - if score > test[2]: - test[2] = score - highScore.set('High score: %s' % (test[2])) + for i in test[1][questionPlace]: + if answerEntry.get().lower() == i.lower(): + score += timeMultiplier + currentScore.set('Score: %s' % (score)) + else: + score = 0 + currentScore.set('Score: %s' % (score)) + if score > test[2]: + test[2] = score + highScore.set('High score: %s' % (test[2])) answerEntry.delete(0, 'end') newQuestion() currentScore.set('Score: %s' % round(score, 2))