Boston Python Workshop 8/Friday/Tutorial: Difference between revisions

imported>Jesstess
imported>Jesstess
Line 558:
====more choices: <code>if</code> and <code>else</code>====
 
You can use the <b><code>elseif</code></b> keywordlet's toyou execute some code whenonly theif a condition is <code>ifTrue</code>. expressionWhat isn'tif True.you Trywant this:to execute different code if a condition is <code>False</code>?
 
Use the <b><code>else</code></b> keyword, together with <code>if</code>, to execute different code when the <code>if</code> condition isn't <code>True</code>. Try this:
 
<pre>
Line 569 ⟶ 571:
</pre>
 
Like with <code>if</code>, the code block under the <code>else</code> statementcondition must be indented so Python knows that it is a part of the <code>else</code> block.
 
====compound conditionals: <code>and</code> and <code>or</code>====
Anonymous user