Advertisement
Danila_lipatov

Untitled

Oct 16th, 2022
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. def check_pali(our_string):
  2. our_string = our_string.lower()
  3. counts = defaultdict(int)
  4. for letter in our_string:
  5. if ord(letter) >= 97 and ord(letter) <= 122:
  6. counts[letter] += 1
  7. # print(counts)
  8. middle = ""
  9. for letter in counts:
  10. if middle and counts[letter] % 2 == 1:
  11. return False
  12. elif counts[letter] % 2 == 1:
  13. middle = letter
  14. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement