python中,输入字符串"I am a student,and you arw a teacher".求包含的单词个数(可以把字符串中各单词存入一个列表)

str =input("I am a student,and you are a teacher")
resoult = {}
for i in str
resoult[i] = str.count(i)
print(resoult)

我写的这个,但是第三行显示语法错误,想问问什么情况呀。那这道题怎么写呀

s ="I am a student,and you are a teacher"
s = s.replace(",", " ")
resoult = {}
for i in s.split():
    resoult[i] = s.count(i)
    
print(resoult)
"""--result
{'I': 1, 'am': 1, 'a': 6, 'student': 1, 'and': 1, 'you': 1, 'are': 1, 'teacher': 1}
"""

count = str.split(' ')