본문 바로가기
코딩/PythonChallenge

[PythonChallenge] Level 2 풀이

by zz! 2024. 5. 9.
728x90

http://www.pythonchallenge.com/

 

The Python Challenge

What people have said about us: "These sorts of things are in my opinion the best way to learn a language.", brberg at Media Cloisters "It's the best web site of the year so far.", Andy Todd at halfcooked "Addictive way to learn the ins and outs of Python.

www.pythonchallenge.com

 

[PythonChallenge] Level 2 풀이

더보기

recognize the characters. maybe they are in the book,
but MAYBE they are in the page source.

 

위에 문구를 먼저 번역을 해봅시다. 

책에 있을지도 모르죠,
하지만 페이지 소스에 있을 수도 있습니다.

라는 번역의 결과가 나왔습니다. "페이지 소스"에 있을 수도 있다고 합니다. 

페이지 소스를 열어서 보면,

 이런 문자를 확인할 수 가 있습니다.

find rare characters in the mess below: 를 또 번역을 해보면, "아래에서 희귀 캐릭터를 찾아보세요:"

라는 결과가 나오고, 아래에서 특수문자를 제외한 다른 문자가 있는 것을 알 수가 있습니다.

열심히 눈을 찾아서 보니, 영어가 희귀한 문자인 것을 알 수가 있습니다. 그래서 파이썬 코드를 짜서 영어 알파벳만 출력을 하도록 해보도록 하겠습니다.

f = open("./test.txt", 'r')
for line in f:
    line = line.strip()
    for char in line:
        if 'a' <= char <= 'z':
            print(char)
f.close()

 저는 이렇게 위에 문자가 매우 길어서 메모장에 따로 저장을 한 후, 한 글자씩 검사를 해서 조건문을 추가해 알파벳만 출력이 되도록 소스코드를 작성하였습니다.

그러면 결과값이 equality가 나오게 됩니다. 이것을 url에 넣으면 다음 문제로 갈 수가 있습니다.

728x90