Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ispoli0(string):
- for i in range(int(len(string)/2)):
- if string[i] != string[len(string)-1-i]:
- return False
- return True
- def ispoli(string):
- def check(char):
- return char.lower() in '''1234567890qwertyuiopasdfghjklzxcvbnm'''
- i, j = 0, len(string) - 1
- while True:
- if i >= j:
- break
- while not check(string[i]):
- i += 1
- while not check(string[j]):
- j -= 1
- if string[i].lower() != string[j].lower():
- return False
- i += 1
- j -= 1
- return True
- print(ispoli(''))
- print(ispoli('a'))
- print(ispoli('ab'))
- print(ispoli('abc'))
- print(ispoli('abcb'))
- print(ispoli('abcbA'))
- print(ispoli('aBCcBA'))
- print(ispoli('a#$BCc&**BA'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement