30-Day Coding Challenge

Days 21, 22, & 23 — Exploring Bools

Kester R.
DSV Logs!
Published in
2 min readJul 28, 2024

--

Photo by Author Via Microsoft Designer & Canva

On days 21, 22 & 23, I played around with bools.

When I first heard that term, I completely misspelled it as “bullian” (What in the world is that 😏?) instead of boolean and had no idea what it meant.

Life of a complete noob.

Time passed, and I’ve used this data type for some of my projects, especially along with the if, else, and elif statements.

But recently, I used the in operator for the first time.

Basically, it’s used to determine if a value is part of a collection of values (either strings, variables, lists, or tuples, which is pretty convenient).

Here’s how it can be used with a dictionary.

e_dict = {1:'one', 2:'two', 3:'three'}

print(1 in e_dict) #checks if '1' is in e_dict
print('four' in e_dict.values()) #checks if 'four' is part of e_dict's values

The outputs will be:

print(1 in e_dict) #True
print('four' in e_dict.values()) #False

In contrast, the not in operator does the reverse of in. It checks if a value is not part of a collection of values.

print('30' not in '30 Day Challenge')

#OUTPUT: False

This, in addition to using the bool function and if statements are the top highlights of days 21–23 of my coding challenge.

The last week of my challenge approaches…

--

--

Kester R.
DSV Logs!

I'm a writer trying to do what he knows best - "hitting the keys on my keyboard"