leetcode.py 274 B

123456789101112131415161718
  1. # Проверка числа на полиндром
  2. def is_polindrom(x: int) -> bool:
  3. if x < 0:
  4. return False
  5. new = 0
  6. orig = x
  7. while x:
  8. x, d = divmod(x, 10)
  9. new = new*10 + d
  10. return new == orig
  11. print(is_polindrom(121))