1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question Python Armstrong Number

Discussion in 'Developer Support' started by jehaz22, Apr 23, 2023.

  1. jehaz22

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

    Code (Text):
    1. import re
    2. from tkinter import *
    3.  
    4. root = Tk()
    5.  
    6. label = Label(root, text="Enter a 7 digit Number")
    7. label.pack()
    8.  
    9. num = Entry(root, width=50, bg="orangered")
    10. num.pack()
    11.  
    12. def myclick():
    13.     Sum = 0
    14.     temp = num
    15.  
    16.     if 1000 > num > 99:
    17.         while temp > 0:
    18.             digit = temp % 10
    19.             Sum += digit ** 7
    20.             temp //= 10
    21.             if num == Sum:
    22.                 label2 = Label(root, num, "is an Armstrong number")
    23.                 label2.pack()
    24.             else:
    25.                 label3 = Label(root, num, "is not an Armstrong number")
    26.                 label3.pack()
    27.     else:
    28.         label4 = Label(root,
    29.                        "The number you entered is not a 7 digit number, Please Enter a number between 100 and 999")
    30.         label4.pack()
    31.  
    32. MyButton = Button(root, text="Click", command=myclick)
    33. MyButton.pack()
    34. 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?
     
  2. exodus4tune

    Joined:
    Apr 23, 2019
    Messages:
    20
    Likes Received:
    11
    -
     
    #2 exodus4tune, Apr 24, 2023
    Last edited: Apr 24, 2023

Share This Page

Loading...