How to set python variables to true or false?
First to answer your question, you set a variable to true or false by assigning True
or False
to it:
myFirstVar = True
myOtherVar = False
If you have a condition that is basically like this though:
if <condition>:
var = True
else:
var = False
then it is much easier to simply assign the result of the condition directly:
var = <condition>
In your case:
match_var = a == b
Python boolean keywords are True
and False
, notice the capital letters. So like this:
a = True;
b = True;
match_var = True if a == b else False
print match_var;
When compiled and run, this prints:
True
match_var = a==b
that should more than suffice
you cant use a - in a variable name as it thinks that is match
(minus) var
match=1
var=2
print match-var #prints -1