Boston Python workshop 2/Friday tutorial: Difference between revisions

Content added Content deleted
Line 358: Line 358:
Use <code>==</code> to test for equality. Recall that <code>=</code> is used for <i>assignment</i> (e.g. <code>my_string == "Hello"</code>).
Use <code>==</code> to test for equality. Recall that <code>=</code> is used for <i>assignment</i> (e.g. <code>my_string == "Hello"</code>).


<code>=</code> is assignment, <code>==</code> is comparison.
This is an important idea and can be a source of bugs until you get used to it: <b>= is assignment, == is comparison</b>.


Use <code>!=</code> to test for inequality:
Use <code>!=</code> to test for inequality: