인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

torms221444's profile image
torms221444

asked

[Renewal] Python Introduction and Basic Crawling Bootcamp [Python, Web, Basic Data Understanding] (Updated)

Python Basics Become Most Natural Through Problem Solving: Utilizing Loops and Various Data Structures 1

45번 문제 질문 있습니다.

Written on

·

200

0

안녕하세요. 45번 문제 풀어보는데 달러로는 잘 나오는데

위안이나 엔도 달러값으로만 나오는것 같습니다.ㅜㅜ

python웹-크롤링

Answer 1

0

funcoding님의 프로필 이미지
funcoding
Instructor

안녕하세요. 답변 도우미입니다.

말씀하신 부분이 어떤 부분이 문제이신지 구체적으로 이해하기는 어려운데요.

 

exchange = {'달러':1112, '위안':171, '엔':1010}

prices = input()

for exchange_item in exchange.keys():

if prices[4:] == exchange_item:

print (int(prices[:4]) * exchange[exchange_item], '원')

에서 prices[4:] 가 달러나 위안이어야 하므로 0~3번까지 숫자를 쓰고, 4번 인덱스에 해당하는 부분부터 위안과 같이 쓰면 좋을 것 같습니다.

예를 들어 1000위안 과 같이 넣으면 다음과 같이 정상동작하는 것을 확인하였습니다.

1000위안
171000 원

감사합니다.

torms221444's profile image
torms221444

asked

Ask a question