1 00:00:00,490 --> 00:00:02,610 A final hello to you all. 2 00:00:02,610 --> 00:00:07,650 Let's take a look at one possible solution to this challenge. 3 00:00:07,650 --> 00:00:11,586 In alphabet.py here, I took this example word_list and 4 00:00:11,586 --> 00:00:17,530 I moved it down inside of Dunder main, so that I could use it to test my code. 5 00:00:17,530 --> 00:00:22,470 I then created a function that I called first_alpha where I pass in 6 00:00:22,470 --> 00:00:25,850 the list as a parameter called words. 7 00:00:25,850 --> 00:00:32,200 And I use the min function to return the first word alphabetically. 8 00:00:32,200 --> 00:00:37,380 Now, if you didn't know already, letters were kind of like numbers in Python. 9 00:00:37,380 --> 00:00:40,705 So for example, a B would be greater than an A, 10 00:00:40,705 --> 00:00:43,420 a D would be greater than a C and so on. 11 00:00:43,420 --> 00:00:48,812 And I can actually show you that here inside of the Python console. 12 00:00:48,812 --> 00:00:54,935 So, if I do B > A, I get it's gonna give 13 00:00:54,935 --> 00:01:00,245 'B' not defined sorry, "b" > "a". 14 00:01:00,245 --> 00:01:03,210 And you see I get True. 15 00:01:03,210 --> 00:01:07,350 So, we can use that to our advantage and use the minimum function Python 16 00:01:07,350 --> 00:01:11,290 has built in min function to return the first word alphabetically. 17 00:01:12,900 --> 00:01:18,788 So, if I run python3 alphabet.py, you can see I get bird, 18 00:01:18,788 --> 00:01:24,050 I'm passing in the word_list to my function. 19 00:01:24,050 --> 00:01:28,173 And it's finding the minimum of that list, which is the word "bird", 20 00:01:28,173 --> 00:01:31,190 which is the one we were looking for. 21 00:01:31,190 --> 00:01:36,010 Now, if you used for loops and conditional statements instead, that's awesome. 22 00:01:36,010 --> 00:01:39,213 There are so many ways to tackle challenges in programming, and 23 00:01:39,213 --> 00:01:42,910 just because my answer is different than yours, doesn't make it wrong. 24 00:01:44,000 --> 00:01:49,120 With all that complete, let's move over into app.py. 25 00:01:49,120 --> 00:01:51,250 Here I imported the alphabet file and 26 00:01:51,250 --> 00:01:55,110 then uncommented these two lines down here at the bottom. 27 00:01:55,110 --> 00:01:58,830 I also wrapped them in print statements, because as you can see in my function, 28 00:01:58,830 --> 00:02:00,990 I chose to do return instead of print. 29 00:02:00,990 --> 00:02:03,970 So, in order to see the response in the console, 30 00:02:03,970 --> 00:02:07,330 I will then have to print out what my function returns. 31 00:02:08,900 --> 00:02:13,287 So, from this first word_list, we should still get bird. 32 00:02:13,287 --> 00:02:18,548 And then from our last_names list we should get my last name "Amendola". 33 00:02:18,548 --> 00:02:23,438 So, if I run python3, now we do app.py, we get bird, 34 00:02:23,438 --> 00:02:27,615 and Amendola, we get the correct responses. 35 00:02:27,615 --> 00:02:32,437 And you notice, I don't see bird, printed out to the console twice, 36 00:02:32,437 --> 00:02:36,772 because I correctly used our dunder main to practice and 37 00:02:36,772 --> 00:02:40,630 test out my function inside of alphabet.py. 38 00:02:40,630 --> 00:02:44,835 But it doesn't run when I run my script. 39 00:02:44,835 --> 00:02:48,839 Perfect, nice work Pythonistas. 40 00:02:48,839 --> 00:02:53,914 As a further challenge if you have another small Python project, I encourage you to 41 00:02:53,914 --> 00:02:58,855 try breaking the project up into multiple files and practice using Dunder main. 42 00:02:58,855 --> 00:03:00,620 Keep up the awesome work.