I am trying to make a number generator yet I ran into a problem. It doesn't recognize configure. I am kind of new to tkinter and with my beginner knowledge with python, it really made my head scratching. This is the code:
from tkinter import messagebox
import random
from tkinter import *
from tkinter import ttk
window = Tk()
window.title("Random Number Generator")
window.geometry('350x200')
title_lbl = Label(window, text="Press the button to generate!").grid(row=0, column=1)
def rannum():
ran = random.randint(0, 10000000)
com = ans_lbl.configure(text=ran)
btn = Button(window, text='Randomize', command=rannum).grid(row=1, column=0)
ans_lbl = Label(window, text='').grid(row=2, column=0)
window.mainloop()
This is the error I recieved :
File "C:\Users\(redacted)\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "c:\Users\(redacted)\Documents\(redacted)\(redacted)", line 15, in rannum
com = ans_lbl.configure(text=ran)
AttributeError: 'NoneType' object has no attribute 'configure'