Reputation: 189
There is a difference when I use assert and raised ValuError, why?
The following code, only stop my script when I use raise ValueError
, assert
does not work.
assert (len(dictA) != len(dictB)), 'Your have an .... error'
if len(dictA) != len(dictB):
raise ValueError('Your have an ... error')
Upvotes: 2
Views: 87
Reputation: 4242
You need to use
assert (len(dictA) == len(dictB))
The error is thrown when the condition evaluates to False.
Upvotes: 3