I plan a mathematical game. I want the randint from label 1 + randint from label 2 to be calculated and then check if my entry is the same as the calculated number.
I want to add z1 to z2 and check if the Entry is the same but I don't know how I can add one random number to the other.
I can't add z1 to z2 so what is the way to do that? Should this happen in the if...else?
from tkinter import * from random import *
fenster = Tk()
fenster.title("Mathe-Spiel")
fenster.geometry("300x300")
def anfang():
z1 =label = Label(fenster, text=(randint(1,100)))
label.pack()
zp=label2 = Label(fenster, text="+")
label2.pack()
z2= label1 = Label(fenster, text=(randint(1,100)))
label1.pack()
a =label3 = Label(fenster,)
label3.pack()
e1=eingabe = Entry(fenster)
eingabe.pack()
e2=z1+z2
def ausgabe():
if (e1==e2):
a.configure(text=(eingabe.get()))
else:
a.configure(text="Falsch")
ergebnis = Button(fenster, text="ergebnis", command= ausgabe)
ergebnis.pack()
anfangsknopf = Button(fenster, text="Fange mit dem Spielen an", command=anfang)
anfangsknopf.pack()
mainloop()