#This works for base-10 only. Other bases might require using text-type objects. def is_Armstrong(n): return n == sum(map(lambda x: int(x)**len(str(n)), str(n)))
- #This works for base-10 only. Other bases might require using text-type objects.
- def is_Armstrong(n):
m = n # Make a copy of n for use obtaining digits.#Bearing in mind that n must be kept available.digits = [] #Store digits here#Get digitswhile (m):digits.append(m%10)m //= 10#Get count of digitsx = len(digits)#Compare original value to sum of digit ^ countreturn n == sum(d ** x for d in digits)- return n == sum(map(lambda x: int(x)**len(str(n)), str(n)))