I don't know the function to check if it's a sentence.

Asked 2 years ago, Updated 2 years ago, 32 views

The question is "Define the function isPalindrome to see if the given word is a sentence".

Test Code

print(isPalindrome('Madam')
print(isPalindrome('hello')
True
False

python python3

2022-09-29 22:53

2 Answers

Slice [::-1]
Upper
If you combine , you'll be able to manage it


2022-09-29 22:53

You create a function that checks for sentences and returns True if it is a sentence, and False if it's a sentence or not a sentence.Accordingly
Compare the beginning and end of a character in one argument, otherwise return False.
Compare the first and last two arguments and return False if they are not the same.
Compare the third from the beginning of the three arguments and the third from the end, otherwise return False.
4 Repeat the above until the end of the string and return True if it does not become False.
If the string is even, it's fine, but if it's odd, any letter in the middle is fine, so
You need to be careful.
Example
ABBA is the sentence
ABCBA is also written
ABCAB is not a sentence.

You will be writing a program like this


2022-09-29 22:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.