fork download
  1. def suma_cyfr(liczba):
  2. suma = 0
  3. while liczba!=0:
  4. suma += liczba%10
  5. liczba = liczba//10
  6. return(suma)
  7. def czy_palindrom(x):
  8. if x<10:
  9. return True
  10. koniec_lewej = 10
  11. while 10*koniec_lewej <x:
  12. koniec_lewej *=10
  13. print(koniec_lewej)
  14. print(x)
  15. while x>=10:
  16. if x%10 != x//koniec_lewej:
  17. return False
  18. x=x%koniec_lewej
  19. x=x//10
  20. koniec_lewej = koniec_lewej//100
  21. 1998 - 1000
  22. 99 - 10
  23. return True
  24. print(czy_palindrom(91344319))
  25.  
Success #stdin #stdout 0.13s 14024KB
stdin
Standard input is empty
stdout
100
91344319
1000
91344319
10000
91344319
100000
91344319
1000000
91344319
10000000
91344319
True