Python Online Compiler
Example: Python program to check the input integer number is an Armstrong number using the for loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python program to check the input integer number is an Armstrong number using the for loop print("Enter the positive integer number:", end=" ") x, r = str (input ()), 0 for i in x: r += int (i) ** len (x) # if x is equal to r, the number is an Armstrong number if int (r) == int (x): print(x, " is an Armstrong number.") else: print(x, " is not an Armstrong number!")
153
Output
Clear
ADVERTISEMENTS