This function checks if a string is a palindrome by comparing a string with it's reverse
(string: str)
| 4 | """ |
| 5 | |
| 6 | def palindromeCheck(string: str) -> str: |
| 7 | """ |
| 8 | This function checks if a string is a palindrome |
| 9 | by comparing a string with it's reverse |
| 10 | """ |
| 11 | |
| 12 | # convert the string to all lower case |
| 13 | lower_string = string.lower() |
| 14 | |
| 15 | # create a reversed version of the string |
| 16 | string_reverse = lower_string[::-1] |
| 17 | |
| 18 | # compare the string with its reverse |
| 19 | if lower_string == string_reverse: |
| 20 | return True # string is a palindrome |
| 21 | else: |
| 22 | return False # string is not a palindrome |
| 23 | |
| 24 | # Test case 1 |
| 25 | print(palindromeCheck("RaCecAr")) # returns True |