[Python] Find dictionary keys with duplicate values

Discussão em 'Python' iniciado por Stack, Setembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    some_dict = {"firstname": "Albert", "nickname": "Albert", "surname": "Likins", "username": "Angel"}


    I would like to return the keys of my dict where their value exists for more than one time.

    Could some one show me how to implement this?

    a_list = []
    for k,v in some_dict.iteritems():
    if v in some_dict.values() and v != some_dict.keys(k):
    a_list.append(k)

    Continue reading...

Compartilhe esta Página