python: recursive check to determine whether string is a palindrome

前端 未结 6 1364
死守一世寂寞
死守一世寂寞 2021-01-19 17:11

My task is to define a procedure is_palindrome, that takes as input a string, and returns a boolean indicating if the input string is a palindrome. In this case a single let

6条回答
  •  孤独总比滥情好
    2021-01-19 17:32

    # ask user to enter any string
    a = raw_input("Enter the string : ")
    #palindrome check
    print (a == a[::-1]) and "String is palindrome" or "String is not palindrome"
    

提交回复
热议问题