More than just true and false
Python has two boolean values available for you to use: True
and False
. Most commonly these boolean values are used to indicate that something is on or off, yes or no, or similar states. Additionally, many python types return "truthy" or "falsey" values depending on their condition when evaluated using the bool()
function.
This exercise is part of the course
Data Types in Python
Exercise instructions
- Create an empty list called
my_list
- Print the truthiness of
my_list
. - Append the string
'cookies'
to my_list - Print the truthiness of
my_list
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create an empty list
my_list = ____
# Check the truthiness of my_list
____(____(____))
# Append the string 'cookies' to my_list
____.____('cookies')
# Check the truthiness of my_list
print(____(____))