So I'm going through the 'Google crash course for Python' and one of the problems was to compare a string to see if it was a palindrome (same backwards as forwards). I assumed that I would need a .lower on the new_string but it was giving me a 'False' on obvious ones like 'kayak' and 'radar', and a 'True' on 'Never Odd or Even'. When I took the .lower out of the code, it all worked. What gives?? Why does Python suddenly not care about case??
Here's the code that worked:
def is_palindrome(input_string):
new_string = ""
reverse_string = ""
for range in input_string:
if input_string.isalpha():
new_string = (input_string)
reverse_string = ''.join(reversed(input_string))
print(reverse_string)
# Compare the strings
if new_string==reverse_string:
return True
return False
and the one that didn't:
def is_palindrome(input_string):
new_string = ""
reverse_string = ""
for range in input_string:
if input_string.isalpha():
new_string = (input_string.lower)
reverse_string = ''.join(reversed(input_string))
print(reverse_string)
# Compare the strings
if new_string==reverse_string:
return True
return False