Get the App
SLTechnology News&Howtos  ›  Development  › 

How python checks whether a given string is a palindrome

Shulou Source: shulou.com Published: 2022-06-01 04:58:23 10月03日 Update

This article mainly introduces python how to check whether a given string is a palindrome, the article is very detailed, has a certain reference value, interested friends must read it!

Check whether the given string is a palindrome

We have discussed how to reverse strings. So palindrome becomes a simple program in Python.

My_string = "abcba" if my_string = = my_string [::-1]: print ("palindrome") else: print ("not palindrome") # Output # palindrome above is all the contents of the article "how to check whether a given string is a palindrome". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Palindromes characters strings checks content articles values interests guys buddies more knowledge procedures industry information information channels channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Docker Redmi Linux