Question: Create a function that checks if a word is a palindrome." | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Question: Create a function that checks if a word is a palindrome."

13th Jun 2017, 6:22 AM
ⓢⓐⓝⓓⓔⓔⓟ
ⓢⓐⓝⓓⓔⓔⓟ - avatar
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
13th Jun 2017, 6:43 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
thanks...
13th Jun 2017, 6:53 AM
ⓢⓐⓝⓓⓔⓔⓟ
ⓢⓐⓝⓓⓔⓔⓟ - avatar
+ 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)...
13th Jun 2017, 7:45 AM
visph
visph - avatar
+ 3
what do u mean by kaith p
13th Jun 2017, 9:09 AM
ⓢⓐⓝⓓⓔⓔⓟ
ⓢⓐⓝⓓⓔⓔⓟ - avatar
+ 2
nahi ...
13th Jun 2017, 9:13 AM
ⓢⓐⓝⓓⓔⓔⓟ
ⓢⓐⓝⓓⓔⓔⓟ - avatar
+ 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 ^^
13th Jun 2017, 9:14 AM
visph
visph - avatar
+ 2
thanks...
13th Jun 2017, 9:18 AM
ⓢⓐⓝⓓⓔⓔⓟ
ⓢⓐⓝⓓⓔⓔⓟ - avatar
0
ka bhai nahi samjha?
13th Jun 2017, 9:09 AM
cruso*
cruso* - avatar
0
nice joke
13th Jun 2017, 9:15 AM
cruso*
cruso* - avatar
- 2
kaith p ke bare me kya khayal hai
13th Jun 2017, 9:07 AM
cruso*
cruso* - avatar