Reformulate as if-statement:

if len(...):
raise ValueError...