
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program to check whether two lists are circularly identical
Here two lists are given. Our task is to check and found weather two given lists are circularly identical or not.
Example
Input : A = [100, 100, 10, 10, 100] B = [100, 100, 100, 10, 10] Output : True
Explanation
True as when these elements in the list will circularly rotate then they would be similar to other given list
Algorithm
Step 1: Create First and Second List. Step 2: Then Lists are converted to map. Step 3: join () method is used for converting the list objects into the string. Step 3: doubling list A and converted to the map. Step 4: compare two list. If result is true then Two Lists are circularly identical and if return false then they are circularly non identical.
Example Code
# Python program to check and verify whether two lists are circularly identical or not A=list() n=int(input("Enter the size of the First List ::")) print("Enter the Element of First List ::") for i in range(int(n)): k=int(input("")) A.append(k) B=list() n1=int(input("Enter the size of the Second List ::")) print("Enter the Element of the Second List ::") for i in range(int(n1)): k=int(input("")) B.append(k) C=list() n3=int(input("Enter the size of the Third List ::")) print("Enter the Element of the Third List ::") for i in range(int(n3)): k=int(input("")) C.append(k) print("Compare First List and Second List ::>") print(' '.join(map(str, B)) in ' '.join(map(str, A * 2))) print("Compare Second List and Third List ::>") print(' '.join(map(str, C)) in ' '.join(map(str, A * 2)))
Output
Enter the size of the First List :: 5 Enter the Element of First List :: 10 10 0 0 10 Enter the size of the Second List :: 5 Enter the Element of the Second List :: 10 10 10 0 0 Enter the size of the Third List :: 5 Enter the Element of the Third List :: 1 10 10 0 0 Compare First List and Second List ::> True Compare Second List and Third List ::> False
- Related Articles
- Check if two lists are identical in Python
- Python Program to Check whether 2 Linked Lists are Same
- Python Program to check if two given matrices are identical
- C# program to check if two matrices are identical
- Java program to check if two given matrices are identical
- Program to check if two given matrices are identical in C++
- Check if two list of tuples are identical in Python
- Program to check whether two sentences are similar or not in Python
- Program to check whether two string arrays are equivalent or not in Python
- Python program to check if two lists have at least one common element
- Program to check whether leaves sequences are same of two leaves or not in python
- Program to check whether String Halves Are Alike in Python
- Golang Program to Check Whether Two Matrices are Equal or Not
- Swift Program to Check Whether Two Matrices Are Equal or Not
- Python Program To Check Two Set Are Equal

Advertisements