
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
# "8zerothree2" → 8032
# "seven73nine" → 7739
# "two53eightfour" → 25384
s1 = "8zerothree2"
s2 = "seven73nine"
s3 = "two53eightfour"
def solution(s):
num_dict = {
"zero": "0",
"one": "1",
"two": "2",
"tree": "3",
"four": "4",
"five": "5",
"six": "6",
"seven": "7",
"eight": "8",
"nine": "9",
}
for str in num_dict:
s = s.replace(str, num_dict[str])
answer = int(s)
return answer
print(solution(s1))
print(solution(s2))
print(solution(s3))
강의를 보면서 파이참에서 eng_quiz.py 코드를 작성하고 실행했는데 아래와 같은 에러가 나옵니다.
"C:\Users\yj\Desktop\workspace\Algorithm Notes\venv\Scripts\python.exe" "C:\Users\yj\Desktop\workspace\Algorithm Notes\Algorithm\eng_quiz.py"
Traceback (most recent call last):
File "C:\Users\yj\Desktop\workspace\Algorithm Notes\Algorithm\eng_quiz.py", line 27, in <module>
print(solution(s1))
^^^^^^^^^^^^
File "C:\Users\yj\Desktop\workspace\Algorithm Notes\Algorithm\eng_quiz.py", line 24, in solution
answer = int(s)
^^^^^^
ValueError: invalid literal for int() with base 10: '80three2'
Process finished with exit code 1
