#过滤标点
#处理标点混在单词里
def count_word_info(s):
if not isinstance(s,str):
return None
new_sentence=""
for i in s:
if i==" " or ((i>="a" and i<="z") or (i>="A" and i<="Z")):
new_sentence+=i
else:
new_sentence+=" "
word_num=len(new_sentence.split())
word_max_length=0
for i in new_sentence.split():
if len(i)>word_max_length:
word_max_length=len(i)
return word_num,word_max_length
print(count_word_info("I am a man!"))