x=True
def stupid():
x=False
stupid()
print x
That is why, ('a' > 'b') is false and ('a' > 'A') is true. Save this answer. Show activity on this post. This is because on the ASCII (American Standard Code For Information Interchange) CHART the letter "a" equates to 97 (in decimal values) while the letter "b" equates to 98 (in the decimal values).
In Python, 1 denotes True , and 0 denotes False . So, the tilde operator converts True to False and vice-versa.
Python bool() function is used to return or convert a value to a Boolean value i.e., True or False, using the standard truth testing procedure.
You can check if a value is either truthy or falsy with the built-in bool() function. According to the Python Documentation, this function: Returns a Boolean value, i.e. one of True or False .
You don't need to declare a function-local variable in Python. The "x=False" is referring to an x local to stupid(). If you really want to modify the global x inside stupid:
def stupid():
global x
x=False
To answer your next question, use global
:
x=True
def stupid():
global x
x=False
stupid()
print x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With