30-Day Coding Challenge

Days 18, 19, & 20 — Set and Setbacks

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

--

Photo by Author Via Microsoft Designer & Canva

It’s been 4 days since my last report.

And while I’m at the start of my 23rd day of coding, I can’t keep letting the reports pile up. So, I’ll combine my report for Days 18 and 20 here.

I know, I know. What about day 19?

Unfortunately, I experienced a repeat of day 10 where I did nothing related to programming.

Another setback for me.

On the plus side, I’ve been able to meet up with the other days of coding.

So, what is the main highlight of days 18 and 20? Sets!

They are similar to lists but are enclosed in {} like dictionaries. I didn’t know of this data type till recently.

I’ve seen people regularly use lists, tuples, and dictionaries in their code but not set.

Unlike lists and tuples, it can’t hold duplicate values. And to access the index of a set, you first have to convert it to a list using the list function like this:

my_set = {1,2,3,4,4}
print(type(my_set)) #to confirm the variable type as set

converted_set = list(my_set)
print(type(converted_set)) #to confirm the variable type as list

print(converted_set[1]) #OUTPUT: 2

My next post will combine days 21, 22, and 23 reports.

Even though my writing has been inconsistent, the challenge continues…

--

--

Kester R.
DSV Logs!

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