1 00:00:00,240 --> 00:00:01,650 So how did you get on? 2 00:00:01,680 --> 00:00:06,480 Did you pay heed to my warning that I used the word set? 3 00:00:07,260 --> 00:00:13,470 So what I want you to come up with with something like this, a set of strings, and I've just used 4 00:00:13,470 --> 00:00:17,310 simple letters here, ABC, and the fourth one is C as well. 5 00:00:18,060 --> 00:00:24,150 Now, if we printed this out, what was going to happen, let's say, for M in my set? 6 00:00:26,430 --> 00:00:27,690 Prince M.. 7 00:00:29,180 --> 00:00:33,980 Now, if you weren't paying attention, you'd expect four things to be printed out, but if you were 8 00:00:33,980 --> 00:00:35,990 paying attention, you'd know that wouldn't happen. 9 00:00:36,250 --> 00:00:38,240 You would get Seab. 10 00:00:39,350 --> 00:00:43,550 And you'd get it over here three times, even though you've put four into the set. 11 00:00:43,850 --> 00:00:49,730 That's because two cities are the same item and sets only take one of each item. 12 00:00:50,570 --> 00:00:54,670 You'll also notice we have SEAB, which isn't the order we put it in. 13 00:00:54,770 --> 00:00:55,820 We want A.B.C.. 14 00:00:56,150 --> 00:00:58,580 If I hit play again, let's see what we get. 15 00:01:00,830 --> 00:01:01,730 BCA. 16 00:01:04,210 --> 00:01:04,930 Run it again. 17 00:01:07,040 --> 00:01:08,960 ABC, we finally get it in order. 18 00:01:09,440 --> 00:01:14,810 Now, this is the tricky thing about sets, you might get ABC on your first try and think, well, I'm 19 00:01:14,810 --> 00:01:16,160 good, I'm good to go. 20 00:01:16,160 --> 00:01:17,330 I can do what I need to do. 21 00:01:18,020 --> 00:01:19,310 And that's it. 22 00:01:19,310 --> 00:01:20,390 My program works. 23 00:01:20,900 --> 00:01:25,460 But you little do you know that next time you run it or your user runs it, you get BGCA. 24 00:01:26,670 --> 00:01:28,750 So sets aren't in order. 25 00:01:29,840 --> 00:01:35,930 As for the fall apart, well, that's pretty straightforward, isn't it, for me in my set, just like 26 00:01:36,290 --> 00:01:41,550 for a in array, of course you could do it, something like this. 27 00:01:42,140 --> 00:01:45,650 There is another solution you could say for. 28 00:01:47,230 --> 00:01:52,430 Index in let's have zero, dot, dot, dot two. 29 00:01:53,320 --> 00:01:54,370 What's my site called? 30 00:01:54,380 --> 00:01:57,820 It's called my set, of course, dot count. 31 00:01:59,520 --> 00:02:04,530 Now, I know I didn't teach this is just an extra thing that you can know, you can count the number 32 00:02:04,530 --> 00:02:11,250 of items in my set and then you can print out that index, which should give us zero one to. 33 00:02:12,780 --> 00:02:13,890 So let's have a look see. 34 00:02:16,240 --> 00:02:18,540 We get zero one, two, three. 35 00:02:19,360 --> 00:02:21,010 Interesting, why is that? 36 00:02:21,280 --> 00:02:26,380 Well, we start on index zero and then we say I want the count, which is three. 37 00:02:26,750 --> 00:02:31,800 So that's going to go from zero to three zero one, two, three, that's four times. 38 00:02:32,290 --> 00:02:35,920 So whenever you're using count, you have to use minus one. 39 00:02:37,100 --> 00:02:40,940 Because of that zero based indexing, again, this is a feature. 40 00:02:41,770 --> 00:02:47,260 Of programming that gets a lot of people gets me sometimes it gets all the pro developers I know and 41 00:02:47,260 --> 00:02:52,780 it's so embarrassing when someone finds the missing minus one and says, hey, do you know about zero 42 00:02:52,780 --> 00:02:53,680 based indexing? 43 00:02:53,800 --> 00:03:00,760 You say, Oh, yeah, I guess I do, but not in this piece of software that you're auditing for me anyway. 44 00:03:01,360 --> 00:03:02,090 That's the homework. 45 00:03:02,250 --> 00:03:04,830 I hope you found it fairly simple and you learn something new.