I'd like to remove duplicates from several lists (in-place). Have tried the following but failed (Python Compiler):
a = [1, 2, 2]
b = [3, 4, 4]
c = [5, 6, 6]
print('===previous')
print(id(a))
print(id(b))
print(id(c))
print('---previous')
for l in (a, b, c):
l = list(dict.fromkeys(l))
print('===middle')
print(id(l))
print('---middle')
print('===after')
print(id(a))
print(id(b))
print(id(c))
print(a)
print(b)
print(c)
print('---after')
I know this is because (Python Variable)
Variables (names) are just references to individual objects.
Just want to ask if any efficient way can achieve this goal, thank you.