Question: 40. An Armstrong number is a positive integer, where the sum of its digits, each raised to the power of the number of digits, is
40. An Armstrong number is a positive integer, where the sum of its digits, each raised to the power of the number of digits, is equal to the integer itself. For example, 371 is an Armstrong number as (33)+(73)+(13)=371. Write a Python function called Armstrong number that takes in as parameters two positive integers and returns a list containing all the Armstrong numbers between and including these two integers. Next, write main code that takes as input from the user two integers. If the user gives bad input, continue to prompt them to try again until they enter two integers that are both positive values. Then, call your function and print the resulting list. Example output (bad input): Example output (good input): Enter an integer: 1 Enter an integer: 100 Enter another integer: 2 Enter another integer: 400 Need a positive integer: 0.5 Armstrong numbers: [153,370,371] Need another positive integer: 3 Bad input! Try again first integer: 4 Try again second integer: 26 Armatrong numbers: {4,5,6,7,8,9}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
