аватар question@mail.ru · 01.01.1970 03:00

The task is "palindrome". Python

Task: on this line, determine whether it is a palindrome (that is, it is true that it is equally read from left to right and right to left)

Entry on the input is supplied without gaps. The length of the line does not exceed 200. The letters of different register are considered different.

Conclusion must be removed YES if the line is a palindrome, and no otherwise.

Example:

Abba yes

qwerq no

  slovo =  str  ( input  ()) x =  len  (slovo) i =  0  x = x -  1  k =  0    when  x - i & gt; = i:   f  slovo [x - i] == slovo [i]:  i +=  1    else :  k =  1    break    if  k ==  1 :   print  ( "no" ")   else :   Print  ( "yes" ")     

The wrong response on the 6th test. I don’t have a concept what word it can be. Someone can come up with?

upd: Tests are checking my code on the site. The program substitutes different words into my code and checks the correctness of my solution. 5 words - correctly. 6 Test - no. I can’t come up with such a word and I don’t know what word the program substituted in this test.

аватар answer@mail.ru · 01.01.1970 03:00

It was still possible to simply compare the original word with him, but the conclusion is the other way around [::-1]. There was such a task on stpic.org) I solved this problem

  Slovo =  str  ( input  ()) a = slovo [::- 1 ]   if  slovo == a:   print  ( "" Yes "" )   else :   print  ( "no" ") r  

Latest

Similar