#๐Ÿ”’ ent() not returning correct

4 messages ยท Page 1 of 1 (latest)

celest tinsel
#
import tkinter as tk
multiword = tk.Tk()
multiword.geometry('720x720')
multiword.title('MultiWord setup')
guess = False
word = tk.StringVar()
hint = tk.StringVar()
g = tk.StringVar()
answer = ''
attempts = 0
ansl = None
def ent():
    global ansl,attempts
    if g.get().lower() == word.get().lower():
        answer = 'Correct.'
    elif attempts < 4:
        answer = 'Incorrect.'
    else:
        answer = 'Game over.'
    ansl.config(text=answer)
    attempts += 1
def go():
    global guess,attempts,ansl
    guess = True
    win2 = tk.Tk()
    win2.geometry('720x720')
    win2.title('MultiWord')
    multiword.destroy()
    ansl = tk.Label(win2,text=answer,font=('SEC Medium_SamsungKoreanM Medium',7))
    ansl.pack()
    hintl = tk.Label(win2,text=hint.get(),font=('SEC Medium_SamsungKoreanM Medium',7))
    hintl.pack()
    guessc = tk.Entry(win2,textvariable=g)
    guessc.place(width=720,height=72,x=0,y=288)
    enter = tk.Button(win2,text='Enter',command=ent,font=('SEC Medium_SamsungKoreanM Medium', 10))
    enter.place(height=72,width=720,x=0,y=432)
    
if not guess:
    mword = tk.Label(multiword,text='Word:',font=('SEC Medium_SamsungKoreanM Medium',7))
    mword.place(x=0,y=0)
    mhint = tk.Label(multiword,text='Hint:',font=('SEC Medium_SamsungKoreanM Medium',7))
    mhint.place(x=0,y=144)
    hintenter = tk.Entry(multiword,textvariable=hint)
    hintenter.place(height=72,width=600,x=120,y=144)
    wordenter = tk.Entry(multiword,textvariable=word)
    wordenter.place(height=72,width=600,x=120,y=0)
    ok = tk.Button(multiword,text='OK',command=go,font=('SEC Medium_SamsungKoreanM Medium', 10))
    ok.place(height=72,width=720,x=0,y=288)
multiword.mainloop()```
It literally cannot return Correct,it should,but it always returns Incorrect or Game over
twilit roverBOT
#

@celest tinsel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

twilit roverBOT
#

@celest tinsel

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.