I post Python tips here on an almost daily basis both for myself and everyone else.
Hope you find this useful.
Write a function to check if a list has duplicates in it.
If the function receives [ 1, 2, 1, 3], it should return true.
To solve this, we can use the property that Python sets contain only unique elements i.e., no duplicates.
We convert the list into a set. Then, we check if both the set and list are of the same length.
They will be of different lengths if the list has duplicates.