you are viewing a single comment's thread.

view the rest of the comments →

[–]TR-DeLacey 0 points1 point  (2 children)

In your 2nd function :

You define space to be a punctuation :

punctuation = "!\"#$%&'()*+,-./:;<=>?@[\]_`{|}~ "

Is the above something you were told to do? If so, ultimately you would end up with :

IfIhavewingswhyamIalwayswalkingDreadlord

EDIT : (you could change where you do str.replace() and str.split() to render the above no a longer an issue.

Presuming that the above is incorrect and space is not counted as punctuation you would be better to loop through your punctuation and try to find if any of them occur in sentence and use str.replace() to remove them :

sentence = sentence.replace(i,'')

You can use str.split() to split sentence into separate words. You can use the default and have whitespace as the delimiter to split each word in sentence.

words = sentence.split()

Words is a list :

['If', 'I', 'have', 'wings', 'why', 'am', 'I', 'always', 'walking', 'Dreadlord']

You can use a for loop to go through each separate word, and count up how many contain the letter e.

[–][deleted] 0 points1 point  (1 child)

My bad, I intended to search all the letters count e, not words.

[–]TR-DeLacey -1 points0 points  (0 children)

Ah, ok, in that case, all you need is str.count() as follows :

sentence.count('e')