Advertisement
dream_4ild

9-И-2 ex.2

Dec 10th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Thu Nov 19 20:43:52 2020
  4.  
  5. @author: Sergey
  6. """
  7. def is_palindrom(a):
  8.     if len(a)%2==0:
  9.         b=int(len(a)/2)
  10.     else:
  11.         b=int((len(a)/2)+1)
  12.     c=0
  13.     for i in range(b):
  14.         if a[i]==a[-i-1]:
  15.             c+=1
  16.     if c != b:
  17.         return False
  18.     else:
  19.         return True
  20.  
  21.  
  22.  
  23. a = int(input())
  24. a=str(a)
  25. if is_palindrom(a):
  26.     print('Является палиндромом')
  27. else:
  28.     while not is_palindrom(a):
  29.         a=int(a)
  30.         a+=1
  31.         a=str(a)
  32.     print(a)
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement