1

I want to check if a sentence is not in a list of sentences.So here I am using "not in" operator , but the problem is it is taking too much time for larger lists.

list_of_sentences = ["How are you" , "Who are you" , "Are you okay"]
string = "What about you?"

so if I want to check string is not in list I do:

if string not  in list_of_sentences:
       append the string to same list(list_of_sentences)

But it is not doing good if the there are Large number of strings to be searched and the size of "list_of_sentences" will grow with time.

So,is there any other which does this in a fastest way?

Narendra
  • 11
  • 5

0 Answers0