Last active
July 28, 2019 08:59
-
-
Save MrSimsek/e090a2d3503feaf5fbd40e0195c777f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Palindrome 0(n) with efficient use of memory | |
def isPalindrome(string): | |
if string == "": | |
return None | |
for index in range(len(string)): | |
if string[index] != string[(len(string) - 1) - (index)]: | |
return False | |
return True | |
example = "" | |
if isPalindrome(example) == True: | |
print(f"Yes, {example} is a palindrome") | |
elif isPalindrome(example) == False: | |
print(f"No, {example} is not a palindrome") | |
else: | |
print(f"Not a word") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment