import string
text ="""
Got this panda plush toy for my daughter's birthday,
who loves it and takes it everywhere. It's soft and
super cute, and its face has a friendly look. It's
a bit small for what I paid though. I think there
might be other options that are bigger for the
same price. It arrived a day earlier than expected,
so I got to play with it myself before I gave it
to her.
"""defwordcount(text):# 去标点for i in string.punctuation:# string.punctuation是string库中的标点集
text=text.replace(i,'')# 小写
text = text.lower()# 字符串分割
text_list = text.split()
new_text_list=[]# 用一个列表记录共有多少字符for i in text_list:if i notin new_text_list:
new_text_list.append(i)
output_dict={}# 用字典保存字符出现的个数for i in new_text_list:
output_dict[i]=text_list.count(i)return output_dict
print(wordcount(text))