30-Day Coding Challenge
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…