dimanche 24 juillet 2016

next used in a loop python

I am a beginner to python and while examining a piece of a code I found the next() function used in a loop as, I presume a variable.However, when I try to implement a different variable an error occurs. So how could this be and what does this do.

P.S. I am working with generators

for next in graph[vertex] - set(path):
        if next == goal:
            yield path + [next]

        else:
            stack.append((next,path+ [next]))
            print(stack)

Aucun commentaire:

Enregistrer un commentaire