Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def merge(old, new):
  """
  Return a new list with all entries in `old` and novel entries in `new`. Duplicates in `new` (but not `old`!) are ignored.
  """
  ret = old.copy() # avoid mutating
  for item in new:
    if item not in ret:
      ret.append(item)
  
  return ret

l1 = [1,2,3,4,5]
l2 = [1,2,3,4,5,6,6,6,7,8,-1,-1]

print(f'l1={l1}')
print(f'l2={l2}')
print('merging')
l3 = merge(l1, l2)
print(f'l1={l1}')
print(f'l2={l2}')
print(f'l3={l3}')