Answer accepted
This commit is contained in:
parent
96d0e5df76
commit
ba6c38c00e
@ -23,7 +23,10 @@ def isPalindrome(s):
|
||||
|
||||
half = len(lower_string)/2
|
||||
# Round the value down since middle value doesn't matter
|
||||
halfdown = int(math.floor(half))
|
||||
if len(lower_string)%2 != 0:
|
||||
halfdown = int(math.floor(half))
|
||||
else:
|
||||
halfdown = int(half)
|
||||
# print(halfup)
|
||||
# print(halfdown)
|
||||
first = []
|
||||
@ -35,16 +38,22 @@ def isPalindrome(s):
|
||||
# print(lower_string[i])
|
||||
first.append(lower_string[i])
|
||||
|
||||
for j in range(halfdown+1, len(lower_string)):
|
||||
second.insert(0, lower_string[j])
|
||||
if len(lower_string)%2 != 0:
|
||||
for j in range(halfdown+1, len(lower_string)):
|
||||
second.insert(0, lower_string[j])
|
||||
|
||||
# print(first)
|
||||
# print(second)
|
||||
else:
|
||||
for j in range(halfdown, len(lower_string)):
|
||||
second.insert(0, lower_string[j])
|
||||
|
||||
print(first)
|
||||
print(second)
|
||||
if first == second:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# print(isPalindrome("A man, a plan, a canal: Panama"))
|
||||
# print(isPalindrome("aa"))
|
||||
print(isPalindrome("0P"))
|
||||
print(isPalindrome("A man, a plan, a canal: Panama"))
|
||||
print(isPalindrome("aa"))
|
||||
print(isPalindrome("0P"))
|
||||
print(isPalindrome("abba"))
|
||||
Loading…
Reference in New Issue
Block a user