- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check if a string contains a palindromic sub-string of even length in Python
Suppose we have a string s. We have to check whether this string contains some even length palindrome or not.
So, if the input is like s = "afternoon", then the output will be True as "afternoon" has even length palindrome "noon".
To solve this, we will follow these steps:
- for i in range 0 to size of string - 1, do
- if string[i] is same as string[i + 1], then
- return True
- if string[i] is same as string[i + 1], then
- return False
Let us see the following implementation to get better understanding −
Example
def solve(string): for i in range (0, len(string)): if (string[i] == string[i + 1]): return True return False s = "afternoon" print(solve(s))
Input
"afternoon"
Output
True
- Related Articles
- Check if a string contains a palindromic sub-string of even length in C++
- Check if a string contains a sub-string in C++
- How to check if a string contains a specific sub string?
- Method to check if a String contains a sub string ignoring case in Java
- Find the count of palindromic sub-string of a string in its sorted form in Python
- Find all distinct palindromic sub-strings of a given String in Python
- Find all palindromic sub-strings of a given string - Set 2 in Python
- Check if a binary string contains all permutations of length k in C++
- Maximum even length sub-string that is permutation of a palindrome in C++
- Check if a string can become empty by recursively deleting a given sub-string in Python
- How to check if a Python string contains only digits?
- Check if a string contains numbers in MySQL?
- Check if a field contains a string in MongoDB?
- Check if a String Contains a Substring in Linux
- Check if string contains another string in Swift

Advertisements