Jun-16-2018, 06:00 AM
Hello everyone
I have just started a new course in python, and i do not normally ask for help until i find myself against the wall
. I am just struggling with a homework, and for some of you it may be easy but, I just cannot figure out how to solve it.
I have to develop a function in python that return the frequency of each word in the string, the function has to convert all words low case and eliminate punctuations:
1. receive as input a string
2. It has to return a dictionary with the following details:
*covert every word in the string into lowercase
*delete all punctuation
Example:
text="hello my friend, are you my friend? I need some help, hello? hello?"
Should return:
{"hello":3,"my":1,"friend":2,"are":1,"I":1,"need":1,"some":1"help":1}
As you can see there is no punctuation,and since the dictionaries has not an order the order of the words can change.
I really need some help
It would be very nice if you could help me i have been trying to solve it for 3 days so far, and have t deliver it for this Sunday.
I will continue trying meanwhile.
Note: I can use
world.split()
word=word.lower()
x.isalpha()

I have just started a new course in python, and i do not normally ask for help until i find myself against the wall

I have to develop a function in python that return the frequency of each word in the string, the function has to convert all words low case and eliminate punctuations:
1. receive as input a string
2. It has to return a dictionary with the following details:
*covert every word in the string into lowercase
*delete all punctuation
Example:
text="hello my friend, are you my friend? I need some help, hello? hello?"
Should return:
{"hello":3,"my":1,"friend":2,"are":1,"I":1,"need":1,"some":1"help":1}
As you can see there is no punctuation,and since the dictionaries has not an order the order of the words can change.
I really need some help



I will continue trying meanwhile.
Note: I can use
world.split()
word=word.lower()
x.isalpha()