Nice try :) but as Adrian suggested it is not recommended to use dunder methods unless you are planning to override some built-in utility function in a class.
Let me provide an alternate one-line solution using comprehensions which I discovered lately :)
email_list = ['roger@hey.com','michael@hey.com','roger@hey.com','prince@gmail.com']
duplicates = list(set([email for email in email_list if email_list.count(email) > 1 ]))
print(duplicates)
Comprehensions look way cool but they can impact the code readability.
Nice try :) but as Adrian suggested it is not recommended to use dunder methods unless you are planning to override some built-in utility function in a class.
Let me provide an alternate one-line solution using comprehensions which I discovered lately :)
Comprehensions look way cool but they can impact the code readability.
Very interesting indeed!