How can I edit the commented-off piece of code so that it returns a dictionary of the duplicate numbers rather than returning "{}"?
listOfElems = ["a", "c", "c"]
def checkIfDuplicates_3(listOfElems):
duplicates = {}
for x in listOfElems:
# duplicates = ??
if listOfElems.count(x) > 1:
return duplicates
return duplicates
#test
test = [listOfElems]
for t in test:
output = checkIfDuplicates_3(t)
print("The duplicate in", t, "is", output)