강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

김동연님의 프로필 이미지
김동연

작성한 질문수

프로그래밍, 데이터 과학을 위한 파이썬 입문

dict 타입의 key - value 프로그램을 value - key로 변경하여 value 값으로 key 찾기

해결된 질문

작성

·

303

1

#함수를 통해서 만들어보면
def reverse_dict(dict_tpye_list):
    temp_dict = {}
    for key , value in dict_tpye_list.items():
        temp_dict[value] = key
    result = temp_dict
    return result

country_code = { "America":1 , "Korea":82 , "France":33,  "Germany":49}
reverse_country_code = reverse_dict(country_code)
print(reverse_country_code)
print(reverse_country_code[82])

답변 1

0

TeamLab님의 프로필 이미지
TeamLab
지식공유자

감사합니다!

김동연님의 프로필 이미지
김동연

작성한 질문수

질문하기