0
hi i need some help please
so,im doing intermediate python and im the project wich i have to take a text and convert it to dict and show the numbers of times that every word appears,and i dont know hot to convert my variable "texto" to a dictionary. Please if someone can help me
1 Answer
+ 3
First is dictionary comprehension and second is looping over string and incrementing dictionary value by 1.
------------------
a="hello"
b={i:0 for i in a}
for i in a:
b[i]+=1
print(b)