My issue
Wrong Answer: Failed on a hidden test case
My code
num = int(input("Enter a number: "))
sum = 0
temp = num
n = len(str(num)) # Number of digits
# Calculate the Armstrong number sum
while temp > 0:
digit = temp % 10 # Extract the last digit
sum += digit ** n # Raise to the power of the number of digits
temp //= 10 # Remove the last digit
# Check if the computed sum matches the original number
if num == sum:
print("Armstrong")
else:
print("Not Armstrong")
Learning course: Roadmap to 3*
Problem Link: https://www.codechef.com/learn/course/klu-roadmap-3star/KLURMP300B/problems/LPYAS151