Skip to content

Instantly share code, notes, and snippets.

@nattybear
Created April 23, 2017 11:05
Show Gist options
  • Select an option

  • Save nattybear/ecb29ddd980d846f5b059a22e340ccdc to your computer and use it in GitHub Desktop.

Select an option

Save nattybear/ecb29ddd980d846f5b059a22e340ccdc to your computer and use it in GitHub Desktop.
알고스팟 URI
table = {"%20" : " ",
"%21" : "!",
"%24" : "$",
"%25" : "%",
"%28" : "(",
"%29" : ")",
"%2a" : "*"}
def convert(string):
for i in table.keys():
string = string.replace(i, table[i])
print(string)
num = int(input())
for i in range(num):
convert(input())
@nattybear

nattybear commented Apr 23, 2017

Copy link
Copy Markdown
Author

문제 풀이 전략

  • 주어진 조건을 파이썬 딕셔너리로 저장
  • 딕셔너리 객체의 keys 함수와 문자열 객체의 replace 함수를 이용하여 반복문을 통해 변환 처리
  • 변환 과정을 함수로 구현하여 재사용

소감

  • 몇달 전에 이 문제에 처음 도전 했을 때는 정답 처리가 되지 않았는데, 오늘 다시 도전해보니 정답이 되었다. 오답과 정답 간의 내 코드의 차이점을 잘 모르겠는데 아무튼 성공!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment