

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to check strings are rotation of each other or not in Python
Suppose we have two English strings s and t, they can be in lowercase and/or uppercase. We have to check whether one is a rotation of the other or not.
So, if the input is like s = "koLKAta" t = "KAtakoL", then the output will be True
To solve this, we will follow these steps −
- if size of s is not same as size of t, then
- return False
- s := s concatenate s
- return True when t is present in s otherwise False
Example
Let us see the following implementation to get better understanding −
def solve(s, t): if len(s) != len(t): return False s = s + s return True if s.find(t) != -1 else False s = "koLKAta" t = "KAtakoL" print(solve(s, t))
Input
"koLKAta", "KAtakoL"
Output
True
- Related Questions & Answers
- Check if strings are rotations of each other or not in Python
- A Program to check if strings are rotations of each other or not?
- Write a program in JavaScript to check if two strings are anagrams of each other or not
- Check whether two strings are anagram of each other in Python
- Check if two strings are anagram of each other using C++
- Check if bits in range L to R of two numbers are complement of each other or not in Python
- Program to check whether every rotation of a number is prime or not in Python
- How to check if two Strings are anagrams of each other using C#?
- C Program to check if two strings are same or not
- Program to check whether final string can be formed using other two strings or not in Python
- Program to check two strings are 0 or 1 edit distance away or not in Python
- Program to check whether one tree is subtree of other or not in Python
- Java Program to check whether two Strings are an anagram or not.
- Check if two strings are equal or not in Arduino
- Program to check whether parentheses are balanced or not in Python
Advertisements