title: raise Assertionerror vs. assert python
body: <p>What are the big differences between <code>raise AssertionError</code> and <code>assert</code> to build in a &quot;fault&quot;? What are the effects on the code? And is one or the other more pythonic in a way?</p>
  <p>The reason for my question is because I am learning to program. Right now we have an exercise where for example when <code>x != 0</code> we need to get an <code>AssertionError</code> &quot;false&quot;.</p>
  <p>I looked this up online, where I found the following code:</p>
  <pre class="lang-py prettyprint-override"><code>if x != 0:
      raise AssertionError (&quot;false&quot;)
  </code></pre>
  <p>But my teachers also use the following a lot:</p>
  <pre class="lang-py prettyprint-override"><code>assert x == 0,&quot;fout&quot;
  </code></pre>
  <p>What are the (dis)advantages of each approach?</p>
  <p>Thanks a lot in advance.</p>