1 00:00:00,870 --> 00:00:02,720 Let's talk about zip. 2 00:00:02,730 --> 00:00:04,290 How can we use zip. 3 00:00:05,280 --> 00:00:14,630 Well let's create a new function and the zip function works kind of like a zipper. 4 00:00:14,750 --> 00:00:22,640 We need to lists or to iterate balls and we can zip them together. 5 00:00:22,660 --> 00:00:24,210 Let me show you what I mean. 6 00:00:24,340 --> 00:00:34,860 Let's say I have my list and then your list and this your list will have 10 20 and 30. 7 00:00:34,950 --> 00:00:37,760 Make sure that it's a list. 8 00:00:37,770 --> 00:00:52,360 There you go and in here with the zip function I can simply run zip and in here I give it as many it 9 00:00:52,360 --> 00:00:53,970 troubles as I want. 10 00:00:53,970 --> 00:00:56,260 In our case two edibles. 11 00:00:56,310 --> 00:01:01,020 So I'm going to give it my list and your list. 12 00:01:02,540 --> 00:01:04,180 Let's close that out. 13 00:01:04,280 --> 00:01:08,630 Add one more bracket and in fact click Run 14 00:01:13,900 --> 00:01:15,560 what just happened here. 15 00:01:15,670 --> 00:01:25,870 Zip like a zipper takes the two it dribbles and grabs the first item from each and zips them together 16 00:01:26,140 --> 00:01:27,010 like a zipper. 17 00:01:27,040 --> 00:01:37,900 So 1 and 10 get added to a couple together then two and 20 get added to topple together and then three 18 00:01:37,900 --> 00:01:41,450 and 30 get added to a couple together. 19 00:01:41,470 --> 00:01:49,620 What if this was a couple like this and I click Run does it matter. 20 00:01:49,620 --> 00:01:54,820 It's an ignorable it's going to zip the items together. 21 00:01:54,860 --> 00:01:58,930 Now this may not seem that useful to you now. 22 00:01:59,090 --> 00:02:05,600 It's actually a very important function that because it's so generic can be used in so many different 23 00:02:05,600 --> 00:02:06,710 things. 24 00:02:06,740 --> 00:02:15,020 For example if we had from a database we collected all the user names from one column in a database 25 00:02:15,260 --> 00:02:22,700 and then maybe from another part of the database we collect all of the phone numbers and they were all 26 00:02:22,700 --> 00:02:23,980 in the same order. 27 00:02:24,050 --> 00:02:33,230 Well we can combine these into a temple using zip that has the user name and the phone numbers attached 28 00:02:33,230 --> 00:02:42,660 to them and create a whole new data structure and if I had a another list here let's say their list 29 00:02:46,550 --> 00:02:57,380 and this one has five four and three I can add again their list as well. 30 00:02:57,380 --> 00:03:03,230 And if I click Run you see that I can keep zipping things together. 31 00:03:03,230 --> 00:03:14,920 So zip iterate over each one of these lists or data structures and zip them together once again noticing 32 00:03:14,920 --> 00:03:19,090 that we don't modify any of our current data. 33 00:03:19,180 --> 00:03:22,130 Instead we create a whole new one. 34 00:03:22,270 --> 00:03:25,060 Very very nice. 35 00:03:25,100 --> 00:03:26,190 What about reduce. 36 00:03:26,840 --> 00:03:28,340 Let's find out more in the next video.