So, basically, I’m attempting to write a Python programme that will determine whether or not the three-digit number entered by the user is an Armstrong number. It works fine in Python, except that it prints the answer three times in the terminal. But when I use tkinter, I have some issues because I only learned about it a few hours ago and don’t really know how to use it. The issue I’m having is with the > operator; I’m receiving data in Entry(), but the > operator is only for integers, so I’m getting type errors.
import re
from tkinter import *
root = Tk()
label = Label(root, text="Enter a 3 digit Number")
label.pack()
num = Entry(root, width=50, bg="orangered")
num.pack()
def myclick():
Sum = 0
temp = num
if 1000 > num > 99:
while temp > 0:
digit = temp % 10
Sum += digit ** 3
temp //= 10
if num == Sum:
label2 = Label(root, num, "is an Armstrong number")
label2.pack()
else:
label3 = Label(root, num, "is not an Armstrong number")
label3.pack()
else:
label4 = Label(root,
"The number you entered is not a 3 digit number, Please Enter a number between 100 and 999")
label4.pack()
MyButton = Button(root, text="Click", command=myclick)
MyButton.pack()
root.mainloop()
Error: TypeError: '>' not supported between instances of 'int' and 'Entry'
All I want is for this programme to run in a graphical environment and to stop printing the result three times. Can anyone assist me?