+ 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 Respuestas
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)