Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Python Armstrong Number

Joined
Mar 20, 2023
Messages
3
Here's the mistake:
'>' is not supported between occurrences of 'int' and 'Entry'.
Here is my code:

Code:
import re
from tkinter import *

root = Tk()

label = Label(root, text="Enter a 7 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 ** 7
            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 7 digit number, Please Enter a number between 100 and 999")
        label4.pack()

MyButton = Button(root, text="Click", command=myclick)
MyButton.pack()
root.mainloop()

So, basically, I'm attempting to write a Python software that will determine whether or not the three-digit number supplied by the user is an Armstrong number. That works perfectly in Python, except that it prints the answer three times in the terminal. However when I use tkinter like in this documentation, 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, therefore I'm getting type problems.

All I want is for this software to run in a graphical environment and to stop reporting the result three times. Can somebody assist me?
 
Top