fork download
  1. node = [['1001', '2008-01-06T02:12:13Z', ['']],
  2. ['1002', '2008-01-06T02:13:55Z', ['']],
  3. ['1003', '2008-01-06T02:13:00Z', ['Lion', 'Rhinoceros', 'Leopard', 'Panda']],
  4. ['1004', '2008-01-06T02:15:20Z', ['Lion', 'Leopard', 'Eagle', 'Panda', 'Tiger']],
  5. ['1005', '2008-01-06T02:15:48Z', ['Lion', 'Panda', 'Cheetah', 'Goat', 'Tiger']],
  6. ['1006', '2008-01-06T02:13:30Z', ['']],
  7. ['1007', '2008-01-06T02:13:38Z', ['Cheetah', 'Tiger', 'Goat']]]
  8.  
  9.  
  10. result = []
  11. seenanimals = set()
  12. for ident, _, animals in node:
  13. for a in animals:
  14. if a not in seenanimals:
  15. result.append([ident, a])
  16. seenanimals.add(a)
  17.  
  18. print(result)
Success #stdin #stdout 0.04s 9316KB
stdin
Standard input is empty
stdout
[['1001', ''], ['1003', 'Lion'], ['1003', 'Rhinoceros'], ['1003', 'Leopard'], ['1003', 'Panda'], ['1004', 'Eagle'], ['1004', 'Tiger'], ['1005', 'Cheetah'], ['1005', 'Goat']]