To preface this, I'm very new to programming so bear with me.
I'm having issues with the syntax for a function I'm writing where I want it to check for duplicate values within a textfile that's been imported and sorted. I want to do this with the following code:
def kollaDublett(dataList):
c = Counter(dataList)
result = [x for x, v in c.items() if v > 1]
dataList is the list I'm checking for duplicates, and I'd like to somehow embedd an if-else
to return either a True or False where result
is defined.
The instructor for this assignment said it was possible to do in a single line but she couldn't really make it work since she doesn't have that much experience in Python.
I can return result
and print its value and it'll show the duplicate, but as I mentioned I would like it to check if there's a duplicate then depending on that returning either a True or False.
Thanks in advance!