Challenge: Testing List Inclusion

Hello,

I am doing the Intermediate Cypher course and I got stuck on a challenge: Testing List Inclusion.
I don't understand why my query (below) is not valid especially concerning how I listed the languages
MATCH (p:Person)--(m:Movie)
WHERE p.name="Actor" and p.name="Drector" AND m.languages IN ["German" , " German"]
RETURN p.name,labels(p), m.languages

Many thanks,
Valentina

I don’t know the requirements, bu I can say that you can’t have p.name = “Actor” and p.name = “ Drector” being true at the same time. ‘Director’ is also misspelled.

Also, is m.languages is a list then the following predicate is not going to give you what you want. It is looking for a list in another list. It will always be false.

m.languages IN ["German" , " German"]

Try this instead:

any(i in m.languages where i in ["German" , " German"])

This will return true if the m.language list contains either “German” or “German”

I assumed you really intended to have two different languages in your list.

Thanks for your reply, the 2 properties true at the same time is something I saw elsewhere and wanted to try, but the spelling mistakes clearly wasn't helping :slight_smile:
I was curious to understand why the way I wrote the languages did not work as I use a similar query in my db, I did intend to have 2 different languages in my list. Thank you for your suggestion, I will try that

1 Like

It would have made since if you had an OR instead of an AND, as the p.name property could be either, just not both.

In your db query, is the attribute a list as m.languages is, or is it a singular value? I suspect the later, in which cause it would work as you expected. Can you post the query part if that still doesn’t explain it?

As a note, the syntax of m.languages in [“German”,”Italian”] is not wrong. It is just that the expression is looking for a list to be a member of a list. For instance assume x=[0,1], then the following is true:

x in [[0,1],2,6]

While x in [0,1,2,6] is false

It is a singular value...I see. Thanks that was very helpful

1 Like