Last active
October 4, 2017 12:22
-
-
Save qlkvg/827e7406916258c1297428f182f8236b to your computer and use it in GitHub Desktop.
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
| from pprint import pprint | |
| from copy import deepcopy | |
| a = [ | |
| ["a", "b", "Xval"], | |
| ["a", "b", "Yval, Zval"], | |
| ["a", "c", "Xval"], | |
| ["a", "d", "Xval"], | |
| ["a", "d", "Yval"], | |
| ["a", "d", "Xval"], | |
| ["a", "e", "Xval"], | |
| ["a", "f", "Xval"], | |
| ["a", "g", "Xval"], | |
| ["a", "h", "Xval"], | |
| ["a", "x", "Xval"], | |
| ["a", "y", "Xval"], | |
| ["a", "z", "Xval"], | |
| ["a", "u", "Xval"] | |
| ] | |
| a.extend(deepcopy(a * 2)) | |
| print(len(a)) | |
| # a += a[::] | |
| for x in range(0, len(a)): | |
| if not a[x][-1] == "DELETED": | |
| for y in range(x+1, len(a)): | |
| if a[x][0] == a[y][0] and a[x][1] == a[y][1]: | |
| for each in a[y][2].split(","): | |
| if not each.strip() in a[x][2]: | |
| a[x][2] += ", {}".format(each.strip()) | |
| a[y].append("DELETED") | |
| pass | |
| pprint([x for x in a if x[-1] is not "DELETED"]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment