- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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 two list of tuples are identical in Python
When it is required to check if two list of tuples are identical, the '==' operator is used.
The '==' operator checks to see if two iterables are equal or not.
A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).
A list of tuple basically contains tuples enclosed in a list.
Below is a demonstration of the same −
Example
my_list_1 = [(11, 14), (54, 58)] my_list_2 = [(98, 0), (10, 13)] print("The first list of tuple is : ") print(my_list_1) print("The second list of tuple is : ") print(my_list_2) my_result = my_list_1 == my_list_2 print("Are the list of tuples identical?") print(my_result)
Output
The first list of tuple is : [(11, 14), (54, 58)] The second list of tuple is : [(98, 0), (10, 13)] Are the list of tuples identical? False
Explanation
- Two list of tuples are defined, and are displayed on the console.
- The tuples are checked for being identical using the '==' operator.
- This is assigned to a value.
- It is displayed on the console.
Advertisements