-
문제 03. 원주율NLP/NLP100 2021. 1. 4. 18:08
"Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." 라는 문장을 단어로 분할하여 각 단어의(알파벳) 글자 수를 앞에서부터 나열한 배열을 만드시오.
s = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." s = s.split(' ') s1 = [len(w.rstrip(',.')) for w in s] print(s1)
[출력 결과]
[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9]
'NLP > NLP100' 카테고리의 다른 글
문제 05. n-gram (0) 2021.01.04 문제 04. 원소 기호 (0) 2021.01.04 문제 02. "shoe" + "cold" = "schooled" (0) 2021.01.04 문제 01. "schooled" (0) 2021.01.04 문제 00. 문자열의 뒤집기 (0) 2021.01.04