Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

truthy falsy python

# use bool() method to find the truthy/falsy value of different objects
# Ex:

# truthy/falsy lists
l = []
print(bool(l))
l = [1]
print(bool(l))

# truthy/falsy integers
n = 0
print(bool(n))
n = 1
print(bool(n))

# truthy/falsy strings
s = ""
print(bool(s))
s = "a"
print(bool(s))

# and so on...
 
PREVIOUS NEXT
Tagged: #truthy #falsy #python
ADD COMMENT
Topic
Name
6+9 =