Function to check that a Python list contains only True and then only False
You can just use x[n_trues:] rather than x[n_trues:len(x)].
Your comments don't really say more than the code. And so I'd recommend removing the comments.
If you want to keep your code documented use docstrings, which can be exported to your documentation via tools like Sphinx.
As commented by Konrad Rudolph, you can remove the and not any(should_be_false) as this will always fail if the all fails.




def check_true_then_false(x):
    """Check first n values are True and the rest are False."""
    return all(x[:sum(x)])




If you want your code to work with iterators, not just sequences then you can instead use:

def check_true_then_false(it):
    """Check first n values are True and the rest are False."""
    it = iter(it)
    # Takes advantage of the iterating side effect, where it consumes the iterator.
    # This allows `all` to simultaneously checks `it` starts with trues and advances `it`.
    return all(it) or not any(it)


For the following two inputs all will result in:

&gt;&gt;&gt; all([True] * n)
True
&gt;&gt;&gt; all([True] * n + [False, ...])
False


However it will mean that it is still [...] as all and any are lazy. Meaning that we just need to check the rest are false. Meaning all slices the iterator for you without you having to. Leaving any with:

&gt;&gt;&gt; any([False] * n)
False
&gt;&gt;&gt; any([False] * n + [True, ...])
True