|
闲的蛋疼,第一个给你做了,太简单了,第二题跟第一题差不多的,实在是不想整了,既然是作业,稍微花五分钟看点资料,第二题也就搞定了
- #coding = utf-8
- #!python3
- import re
- InputStr = input('please input your sentence:\n')
- WordList = re.split('[\s|,|\?|\.|!|;|:|"|\'|(|)|—]+',InputStr)
- print(WordList)
- print('The words number is : {}'.format(len(WordList)))
- l = ''
- for word in WordList:
- l +=word
- print('The words average length is : {}'.format(len(l)/len(WordList)))
复制代码 |
|