'How to fix problem that loop makes function work several times? Python
I'm trying to make hangman game. In this function I have the right answer checking, function play_again() makes window pop up that asks if you want to play again, but here I have a problem, sometimes (not always) when I guess the word right, the play again window pops up several times, and I can't find what the problem is. Would be nice if somebody could help me.
if veiktie_mineejumi < 11:
txt = list(secretword_ar_atstarpeem)
uzmineetie = list(minamie_burti.get())
if secretword_ar_atstarpeem.count(burts) > 0:
for c in range(len(txt)):
if txt[c] == burts:
uzmineetie[c] = burts
average_burtu_mineejumi =+ 1
minamie_burti.set("".join(uzmineetie))
if minamie_burti.get()==secretword_ar_atstarpeem:
messagebox.showinfo("Hangman", "Tu uzminēji!")
uzmineetie_vaardi =+ 1
imgLabel.config(image=bildes[0])
play_again()
else:
veiktie_mineejumi += 1
average_burtu_mineejumi =+ 1
imgLabel.config(image=bildes[veiktie_mineejumi])
#imgLabel.config(image=bildes_prieksh_skolas_pc[veiktie_mineejumi])
if veiktie_mineejumi == 11:
messagebox.showinfo("Hangman", "Spēle ir beigusies, tu neuzminēji vārdu!")
zaudeetaas_speeles =+ 1
imgLabel.config(image=bildes[0])
play_again()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
