Determining if string is palindrome

前端 未结 4 797
Happy的楠姐
Happy的楠姐 2020-12-20 18:43

I wrote two simple functions to determine if a string is a palindrome. I thought they were equivalent, but 2 doesn\'t work. Why is this?

1



        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-20 19:35

    str = input("Enter a string")
    print("\n".join(["Inserted string is" + "NOT"*((str[::-1])!=str)+ " a palindrome"]))
    

提交回复
热议问题