Hello,
pyscript is crashing if count = 0 declare inside def check(guess):
otherwise i get local variable 'count' referenced before assignment
BTW anyone know a good compiler easy to use and light to install?
Thank you
pyscript is crashing if count = 0 declare inside def check(guess):
otherwise i get local variable 'count' referenced before assignment
import tkinter from random import randint from tkinter import messagebox low = 0 high = 10 rand = randint(low,high) print(rand) essai = 10 count = 0 def check(guess): while(guess!=rand): if guess < rand: txtMess.configure(text = 'Trop bas') elif guess > rand: txtMess1.configure(text = 'Trop haut') else: txtMess2.configure(text = f"Bravo! {guess} est le bon nombre") count = count + 1 print('count',count) tk = tkinter.Tk() tk.title('Deviner le nombre') label = tkinter.Label(tk, text = f"Devinez un nombre entre {low} et {high} inclusivement") label.pack() entry = tkinter.Entry(tk) entry.pack() button = tkinter.Button(tk, text = 'Devine', command = lambda: check(int(entry.get())) ) button.pack() txtMess = tkinter.Label(tk, text = "") txtMess.pack() txtMess1 = tkinter.Label(tk, text = "") txtMess1.pack() txtMess2 = tkinter.Label(tk, text = "") txtMess2.pack() tk.mainloop()Any explaination for that?
BTW anyone know a good compiler easy to use and light to install?
Thank you