Python Forum

Full Version: bool b = (num == 100) this doesn't work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
bool b = num == 100
why this doesn't work?
num = 100
bool(num)
bool(num) == 100
num == 100
b = num == 100
b
Output:
True False True True
What do you expect that line to do?

Python doesn't declare the type of the variable, so you wouldn't say
int x = 10
So if you get rid of the bool at front you end up with

b = num == 100
which can be parsed as

b = (num == 100)