So how did you get on?
Did you pay heed to my warning that I used the word set?
So what I want you to come up with with something like this, a set of strings, and I've just used
simple letters here, ABC, and the fourth one is C as well.
Now, if we printed this out, what was going to happen, let's say, for M in my set?
Prince M..
Now, if you weren't paying attention, you'd expect four things to be printed out, but if you were
paying attention, you'd know that wouldn't happen.
You would get Seab.
And you'd get it over here three times, even though you've put four into the set.
That's because two cities are the same item and sets only take one of each item.
You'll also notice we have SEAB, which isn't the order we put it in.
We want A.B.C..
If I hit play again, let's see what we get.
BCA.
Run it again.
ABC, we finally get it in order.
Now, this is the tricky thing about sets, you might get ABC on your first try and think, well, I'm
good, I'm good to go.
I can do what I need to do.
And that's it.
My program works.
But you little do you know that next time you run it or your user runs it, you get BGCA.
So sets aren't in order.
As for the fall apart, well, that's pretty straightforward, isn't it, for me in my set, just like
for a in array, of course you could do it, something like this.
There is another solution you could say for.
Index in let's have zero, dot, dot, dot two.
What's my site called?
It's called my set, of course, dot count.
Now, I know I didn't teach this is just an extra thing that you can know, you can count the number
of items in my set and then you can print out that index, which should give us zero one to.
So let's have a look see.
We get zero one, two, three.
Interesting, why is that?
Well, we start on index zero and then we say I want the count, which is three.
So that's going to go from zero to three zero one, two, three, that's four times.
So whenever you're using count, you have to use minus one.
Because of that zero based indexing, again, this is a feature.
Of programming that gets a lot of people gets me sometimes it gets all the pro developers I know and
it's so embarrassing when someone finds the missing minus one and says, hey, do you know about zero
based indexing?
You say, Oh, yeah, I guess I do, but not in this piece of software that you're auditing for me anyway.
That's the homework.
I hope you found it fairly simple and you learn something new.