+ 2
Question: Create a function that checks if a word is a palindrome."
10 Answers
+ 5
Got this done in Python, maybe it will be hintful and not giving away all the secrets of the trade :)
https://code.sololearn.com/cR4DVjNP4rXd/?ref=app
+ 5
thanks...
+ 4
@Kuba: doing this with Python is trivial, because of slice notation allowing simply reverse a string :P
@Sandeep Kumar:
Palindrome are words (or sentences) which have property to be composed by same letters sequence in both directions (left to right and right to left)...
To check if a word is a palindrome, you'll need to iterate over each letter in both direction to check if letter sequence is the same, or reverse the string and compare to initial value... In all case, you have to iterate over the string backward, so java function to reverse a string:
public static String rev(String txt) {
int c = txt.length();
String t = "";
while (c--!=0) {
t += txt.charAt(c);
}
return t;
}
Implementation of second solution and using above function:
https://code.sololearn.com/co9VPgM8SToU/#java
You can adapt it to write a palindrome checker function, and improve it by handling special cases as spaces in user entry (at least display error message, or better check each word, and/or even check sentence :P)...
+ 3
what do u mean by kaith p
+ 2
nahi ...
+ 2
@cruso*:
4 months ago you was able to read and write english...
Please continue to do this effort, and don't become a spammer ^^
+ 2
thanks...
0
ka bhai nahi samjha?
0
nice joke
- 2
kaith p ke bare me kya khayal hai