Oct-01-2020, 03:16 PM
Thanks, I see.
Interested why the print output differs in lines 8,9.
Interested why the print output differs in lines 8,9.
lst = [3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 40, 40, 50] dup_free = [] dup_free_set = {3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 40, 40, 50} for x in lst: if x not in dup_free: dup_free.append(x) dup_free_set.add(x) print(dup_free) print(dup_free_set) #[3, 22, 1, 4, 5, 6, 10, 20, 40, 50] #{1, 3, 4, 5, 6, 40, 10, 50, 20, 22}