03 円周率
問題
“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."
words = s.replace(',', '').replace('.', '').split(" "); # 不要文字を取り除いて、スペースで区切るresult = []for word in words: result.append(len(word)) # 単語の長さをリストに加えていく
print(result)