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