Return True if s is a palindrome otherwise return False. >>> all(is_palindrome(key) == value for key, value in test_data.items()) True
(s: str)
| 19 | |
| 20 | |
| 21 | def is_palindrome(s: str) -> bool: |
| 22 | """ |
| 23 | Return True if s is a palindrome otherwise return False. |
| 24 | |
| 25 | >>> all(is_palindrome(key) == value for key, value in test_data.items()) |
| 26 | True |
| 27 | """ |
| 28 | |
| 29 | start_i = 0 |
| 30 | end_i = len(s) - 1 |
| 31 | while start_i < end_i: |
| 32 | if s[start_i] == s[end_i]: |
| 33 | start_i += 1 |
| 34 | end_i -= 1 |
| 35 | else: |
| 36 | return False |
| 37 | return True |
| 38 | |
| 39 | |
| 40 | def is_palindrome_traversal(s: str) -> bool: |