Advertisement
gubichas

Проверка на палиндром

Oct 19th, 2022 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import string
  2.  
  3. def isPalindrome(s):
  4.     s=s.lower()
  5.     string.punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
  6.     for p in string.punctuation:
  7.         if p in s:
  8.             s = s.replace(p, '')
  9.     return s == s[::-1]
  10. def check_tests(list):
  11.     i =0
  12.     answ = []
  13.     is_palindrom = ' is palindrom'
  14.     not_palindrom = ' is not palindrom'
  15.     while(i<len(list)):
  16.         str = '{} of example:'.format(i)
  17.         if(isPalindrome(list[i])):
  18.             str = str + is_palindrom
  19.         else:
  20.             str = str + not_palindrom
  21.         answ.append(str)
  22.         i +=1
  23.     return answ
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement