What should return doc.ents if the doc have no entities, in spacy? I want to answer this question: "How many sentences contain named entities given a doc?"
and I have this piece of code as solution

nb = 0

for sent in list(doc.sents):
    if sent.ents:
        nb = nb+1

print(nb)


But I am a little confused about how the if-statement work; 
consider that the actual sentence(sent) does not have any entities(ents), so sent.ents will return an empty list I suppose and I can't understand why an empty list is considered as a false statement because the program when executed does not enter the if.
You could just test whether the tuples entities has any elements:

for sent in list(doc.sents):
    if len(sent.ents) &gt; 0:
        nb = nb+1


Edit: For the purpose of evaluating boolean expressions (as in case of if statements), empty lists are evaluated as false, even though they don't explicitly equal False. Expanding your example with some print statements:

nb = 0
spacy_nlp = spacy.load("de_core_news_md")
text = "Nichts. Auch nichts."
doc = spacy_nlp(text)
for sent in list(doc.sents):
    print("type of ents: " + str(type(sent.ents)) + " with " + str(len(sent.ents)) + " elements.")
    if sent.ents:
        nb = nb+1

print(nb)


Results in:

type of ents: &lt;class 'list'&gt; with 0 elements.
type of ents: &lt;class 'list'&gt; with 0 elements.
0