1 00:00:00,850 --> 00:00:02,350 - [Instructor] In this self check exercise 2 00:00:02,350 --> 00:00:03,930 I'd like you to use the techniques 3 00:00:03,930 --> 00:00:06,720 that I just demonstrated to you in the preceding video 4 00:00:06,720 --> 00:00:09,930 to show the top three trending topics for today 5 00:00:09,930 --> 00:00:11,220 in the United States. 6 00:00:11,220 --> 00:00:14,640 And for that purpose you'll use this WOEID. 7 00:00:14,640 --> 00:00:16,453 So go ahead and give that a shot 8 00:00:16,453 --> 00:00:18,533 then come back to see the answer. 9 00:00:22,770 --> 00:00:26,040 Okay let's start revealing the answer to this exercise. 10 00:00:26,040 --> 00:00:29,910 So first up we want to acquire the U.S. trends 11 00:00:29,910 --> 00:00:31,860 so again this is going to be a list 12 00:00:31,860 --> 00:00:34,800 containing one dictionary for the United States 13 00:00:34,800 --> 00:00:37,290 which has the WOEID that you see here. 14 00:00:37,290 --> 00:00:39,006 So we'll go ahead and grab that. 15 00:00:39,006 --> 00:00:41,370 And you might have noticed there was a little delay there 16 00:00:41,370 --> 00:00:43,990 while that executed to get us the results. 17 00:00:43,990 --> 00:00:46,880 We want to acquire from that dictionary 18 00:00:46,880 --> 00:00:49,410 the trends list for the United States 19 00:00:49,410 --> 00:00:52,200 so we go into element zero of the list 20 00:00:52,200 --> 00:00:53,760 that was returned back here 21 00:00:53,760 --> 00:00:57,130 then we access that dictionary's trends key 22 00:00:57,130 --> 00:00:59,750 which gives us back the trends that we need. 23 00:00:59,750 --> 00:01:03,340 And once again we're going to filter those tweets 24 00:01:03,340 --> 00:01:04,830 by tweet volume 25 00:01:04,830 --> 00:01:08,030 and we're going to sort them in descending order 26 00:01:08,030 --> 00:01:13,030 by only those tweets that have the value 10,000 or more. 27 00:01:13,350 --> 00:01:15,540 So again this value will be none 28 00:01:15,540 --> 00:01:17,560 if it's fewer than 10,000 tweets 29 00:01:17,560 --> 00:01:19,330 anything with 10,000 tweets or more 30 00:01:19,330 --> 00:01:21,260 will have an actual tweet count. 31 00:01:21,260 --> 00:01:23,723 So we'll first filter out anything that doesn't have 32 00:01:23,723 --> 00:01:26,950 or filter out anything that does have none in it 33 00:01:26,950 --> 00:01:31,210 so we have only trends with 10,000 tweets or more 34 00:01:31,210 --> 00:01:33,400 then we'll go ahead and sort those 35 00:01:33,400 --> 00:01:37,810 once again by that tweet volume key in reverse order. 36 00:01:37,810 --> 00:01:41,280 So that will give us the list in the format that we need 37 00:01:41,280 --> 00:01:45,300 and then finally we wanted to show just the top three 38 00:01:45,300 --> 00:01:47,400 trends for the United States today 39 00:01:47,400 --> 00:01:49,380 so we'll go ahead and execute this loop 40 00:01:49,380 --> 00:01:52,900 which accesses a slice of the U.S. list 41 00:01:52,900 --> 00:01:57,490 and as you can see we have today's top three topics 42 00:01:57,490 --> 00:02:00,642 as of right now when I'm performing this video recording 43 00:02:00,642 --> 00:02:03,190 for the United States. 44 00:02:03,190 --> 00:02:07,360 And if you execute this code again on a different day 45 00:02:07,360 --> 00:02:08,920 when you're watching the video, 46 00:02:08,920 --> 00:02:11,510 you'll get whatever the current trending topics are 47 00:02:11,510 --> 00:02:14,370 and if you do it at multiple times during the day 48 00:02:14,370 --> 00:02:17,800 it is possible based on the virality of the trends 49 00:02:17,800 --> 00:02:20,040 that the order of these will change 50 00:02:20,040 --> 00:02:23,183 or that the topics themselves will change as well.