py_challenge#1.Palindrome string(s) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

py_challenge#1.Palindrome string(s)

I recently started learning Python. You only learn it by using it! This is a small task published in GeeksforGeeks. Let's vote for the best solution! Given a string, write a python function to check if it is palindrome or not. A string is said to be palindrome if reverse of the string is same as string. For example, "radar" is palindrome, but "radix" is not palindrome. Examples: Input : malayalam Output : Yes Input : geeks Output : No --from GeeksforGeeks:Python

19th Jun 2017, 9:40 PM
S Liu
S Liu - avatar
6 Answers
19th Jun 2017, 11:55 PM
Ulisses Cruz
Ulisses Cruz - avatar
20th Jun 2017, 4:42 AM
Bàng Tứ Cường
Bàng Tứ Cường - avatar
+ 2
Hi all, thank you for sharing your codes! Let's set a dealine of Berlin time 0 o' clock this Friday... I am currently trying to design for a unitest, not for sure yet... If I succeed, the finnal performance would be determined by both test and vote. Have fun!
20th Jun 2017, 7:45 AM
S Liu
S Liu - avatar
+ 2
Hi, as it is approaching Friday, we are closing this challenge. You all did the work correctly to recognize a Palindrome string. Ulisses used string reverse method, Bang and Bogdan used for loop to solve the issue, and Robin gave an interaction possibillity~ Well done, guys. As I mentioned before, we will chose the one with most votes, so Ulisses you got it! Also, when I think of unitest, I found that my description was quite unclear. So I decide to open a second challenge with it. You are all invited. For a first glance, here is the unitest, not fully done yet though~ https://code.sololearn.com/cDrQgxmyNQB1/?ref=app
22nd Jun 2017, 8:39 PM
S Liu
S Liu - avatar
+ 1
def is_palindrome(str): return (not (False in [str[i]==str[-i-1] for i in range(len(str)//2)])) Yes, this could be solved in simpler ways, but this is the beauty of programming - finding interesting new ways of solving things :)
20th Jun 2017, 7:39 AM
Bogdan Sass
Bogdan Sass - avatar
+ 1
just check my code so efficient and logical: https://code.sololearn.com/cVSjBfmAg16M/?ref=app
21st Jun 2017, 9:05 PM
Robin sharma
Robin sharma - avatar