File size: 327 Bytes
c626d10
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
def keep_last_occurrences(lst):
    last_occurrences = {}
    result = []

    for index, string in lst:
        last_occurrences[index] = string

    for index, string in lst:
        if last_occurrences[index] == string:
            result.append((index, string))
            last_occurrences[index] = None

    return result