본문 바로가기
프로그램

[파이썬] 문제 : 나라 정보 딕셔너리에 나라명 입력으로 정보 출력

by 오디세이99 2023. 11. 30.
728x90
반응형

countries = {}
countries['china'] = 'long history'
countries['russia'] = 'cold and huge'
countries['japan'] = 'fushi mountain'

country = input('')  # 단어 입력 받기

if country in countries.keys():   # in 으로 딕셔너리에 있는지 확인
    print(countries[country])      # 단어가 있으면 value 값 출력
else:
    print('nothis country')

728x90
반응형

댓글