Last active
November 20, 2015 09:56
-
-
Save nutszebra/bb1d2b8fbd03e2436ef5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
#Link: http://www.cl.ecei.tohoku.ac.jp/nlp100/ | |
""" | |
Question 03: | |
03. 円周率 | |
"Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." | |
という文を単語に分解し,各単語の(アルファベットの)文字数を先頭から出現順に並べたリストを作成せよ. | |
""" | |
import re | |
sentence = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." | |
print("".join([re.sub(r"\w+", str(len(re.findall(r"\w+",word)[0])), word) for word in sentence.split()])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment