Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. def ispoli0(string):
  2. for i in range(int(len(string)/2)):
  3. if string[i] != string[len(string)-1-i]:
  4. return False
  5. return True
  6.  
  7. def ispoli(string):
  8.  
  9. def check(char):
  10. return char.lower() in '''1234567890qwertyuiopasdfghjklzxcvbnm'''
  11.  
  12. i, j = 0, len(string) - 1
  13.  
  14. while True:
  15. if i >= j:
  16. break
  17. while not check(string[i]):
  18. i += 1
  19. while not check(string[j]):
  20. j -= 1
  21. if string[i].lower() != string[j].lower():
  22. return False
  23. i += 1
  24. j -= 1
  25. return True
  26.  
  27. print(ispoli(''))
  28. print(ispoli('a'))
  29. print(ispoli('ab'))
  30. print(ispoli('abc'))
  31. print(ispoli('abcb'))
  32. print(ispoli('abcbA'))
  33. print(ispoli('aBCcBA'))
  34. print(ispoli('a#$BCc&**BA'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement