Make a program which accepts a 3 digit number from user and check & confirms whether it is
an Armstrong number or not. Proper message should be displayed as the result.
Interface should be attractive and Numbers should be between 100 - 999.
Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself.
while True:
n = input('Enter number between 100 and 999: ')
if n.isdigit() and 99 < int(n) < 1000:
break
else:
print('Error: wrong input!')
if int(n) == sum([int(d) ** 3 for d in n]):
print(n, 'is Armstrong number!')
else:
print('Sorry,', n, 'isn\'t Armstrong number!')
Comments
Leave a comment