+ 1
(A time limit)Given the string, check if it is a palindrome.
[execution time limit] 4 seconds (py3) Hereâs my code, I want to know how to make it faster,thank you very much á(á)á def checkPalindrome(inputString): inputString = input("Please output a string: ") if len(inputString) < 10**5 and len(inputString) > 1 : return (inputString == inputString[::-1])
3 Answers
0
def checkPalindrome(inputString):
reverseString=((inputString)[::-1])
if inputString==reverseString:
return True
else:
return False
0
that's fasterđ
0
str = input()
print (True if str == str[::-1] else False)
and you can just turn it in to a function by doing
def pal(str)
print (True if str == str[::-1] else False)