vendredi 17 mai 2019

Which algorithm python uses to check existence of string in a list?

I want to know which algorithm python uses to check if an item exists in a list?

The following code in python:

if word in text:
    print(word)

We can apply brute-force equivalent to the code as:

for w in text:
    if(word==w):
        print(word)

But how python actually do this?

Aucun commentaire:

Enregistrer un commentaire