fork download
  1. def opCode(num: int) -> bool:
  2. temp = n = num # int(input("Enter a number:"))
  3. a = 0
  4. while n != 0:
  5. a += (n % 10) ** 3
  6. n = n // 10
  7. return a == temp
  8. # if a == temp:
  9. # print("It's an armstrong number.")
  10. # else:
  11. # print("It's not an armstrong number.")
  12.  
  13. def spiritOfBadcode(num: str) -> bool:
  14. return int(num) == sum(int(x)**3 for x in list(num))
  15.  
  16. for i in range(100, 1000):
  17. op = opCode(i)
  18. sob = spiritOfBadcode(str(i))
  19. if sob:
  20. print(f"{i} is an armstrong number.")
  21.  
  22. if op != sob:
  23. print("The bad code is wrong!")
  24. break
  25.  
  26.  
Success #stdin #stdout 0.03s 9264KB
stdin
Standard input is empty
stdout
153 is an armstrong number.
370 is an armstrong number.
371 is an armstrong number.
407 is an armstrong number.