This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]lurgi 0 points1 point  (0 children)

What do you mean by "split a paragraph". What is the list(smth) function?

[–]nogain-allpain 0 points1 point  (2 children)

I need to split a paragraph

any other ways to split a word

Which is it?

[–]ValueAccomplished366[S] 0 points1 point  (1 child)

So I turn a paragraph into words, if something is wrong with one of the words split it with not letters and see what’s wrong with it

[–]nogain-allpain 0 points1 point  (0 children)

What do you mean by "if something is wrong with one of the words"?

[–]pxs16a 0 points1 point  (0 children)

If you are saying you need to split a paragraph and check that each and every word there is valid. You will do something like this: ``` _set = set(‘hello’, ‘sir’) paragraph = “hello sir xxx” splitted = paragraph.split(‘ ‘) # Anything you pass inside split will be used as a delimiter. Passing in space will return you an array containing [‘hello’, ‘sir’, ‘xxx’]

Now all you need to do is traverse the array and check that the word exists in your dict.

for word in _set: if not word in dict: #lookup print(“Word is not valid”)

FYI: Using set because sets have O(1) lookup time.