python程序题需要大家的帮助

从键盘输入一个英文句子或单词组成的字符串,可以不包含标点符号,但单词之间要用空格分开。用列表统计句子中每个单词的出现频次,以列表形式输出字符串以及每个单词对应频次。(提示:字符串的split方法可以将字符串转成列表)
输入样例:

I am Chinese student and I am studying in Henan University of Technology
输出样例:

I am Chinese student and I am studying in Henan University of Technology 
2 2 1 1 1 2 2 1 1 1 1 1 1 


a=input().split()
b=dict()
for x in a:
    if x in b:
        b[x]+=1
    else:
        b[x]=1

for x in a:
    print(b[x],end=' ')

s = input() #输入
words = s.split() # 分割字符串

mp = {} #字典 存储出现的次数
for word in words: #遍历
    if word in mp: #如果字典里有,次数+1
        mp[word] += 1 
    else:#字典里没有,设置为1
        mp[word] = 1 

a = [] 
for word in words: #次数
    a.append(mp[word])

#打印
for word in words: 
    print(word, end=" ") 
print()
for cnt in a:
    print(cnt, end=" ") 

img


from collections import Counter
str = input()
words = str.replace(',','').replace('.','').split()
count = dict( Counter(words) )   #统计每个单词出现的次数


print(str)
for num in words:
    print( count.get(num),end=' ' )