Cypher & Neo4j : for loop with Cypher request

I have a list of words that I want to use as seed labels in Neo4j.

These labels are renewed everyday so I would like to automate my Cypher requests.

Here is the list I have today:

List : list_of_labels = ['crise sanitaire', 'face crise', 'confinement avril', 'crise coronavirus', 'virus guerre']

I tried this with variables in my Cypher requests:

def create_seed_property(tx, i): j = 0 while j < len(list_of_labels): tx.run(" MATCH (n:ARTICLE {label: $i}) SET n.seed_label = $j RETURN n ") j +=1

And next I did this:

for i in list_of_labels: session.read_transaction(create_seed_property(i))

I don't know where I'm wrong.

You can use UNWIND to process elements of a list. Provided you pass the list_of_labels as a parameter, you can process it like so:

UNWIND $list_of_labels as seed_label
MATCH (n:ARTICLE {label: $i}) 
SET n.seed_label = seed_label 
RETURN n