Created
June 2, 2022 17:38
-
-
Save izikeros/96c5bd7d76e2b01f9e355f7e75fc84f1 to your computer and use it in GitHub Desktop.
Code snippet example for medium article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def check_lists_equal_nested(list_1: list, list_2: list) -> bool: | |
| """ | |
| Check if two nested lists have the same dictionaries | |
| :param list_1: list | |
| :param list_2: list | |
| :return: bool | |
| """ | |
| # 1. Check if two top-level lists have the same length | |
| if len(list_1) != len(list_2): | |
| return False | |
| # 2. Check if each pair of lower-level lists have the same length | |
| for i in range(len(list_1)): | |
| if len(list_1[i]) != len(list_2[i]): | |
| return False | |
| # 3. Check if each pair of lower-level lists have the same keys and values | |
| for i in range(len(list_1)): | |
| for j in range(len(list_1[i])): | |
| if list_1[i][j] != list_2[i][j]: | |
| return False | |
| return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment