1 00:00:00,009 --> 00:00:05,829 Welcome back. So now let's move on to the first main function for the program 2 00:00:06,130 --> 00:00:09,119 that would allow the user to register. 3 00:00:09,270 --> 00:00:10,229 All right. So 4 00:00:10,619 --> 00:00:13,649 let's go all the way to the top in here and let's push 5 00:00:14,350 --> 00:00:18,680 the user interface function all the way down. And let's come up here. 6 00:00:18,879 --> 00:00:23,719 Actually, I'm just going to add a note and say regis registration 7 00:00:24,729 --> 00:00:25,870 uh function. 8 00:00:27,059 --> 00:00:27,840 OK. 9 00:00:28,889 --> 00:00:34,909 OK. So what do we call the function? Let's say register 10 00:00:35,520 --> 00:00:36,669 underscore user. 11 00:00:37,330 --> 00:00:37,909 All right, 12 00:00:38,349 --> 00:00:42,150 we're just a user brackets. Let's add a colon. 13 00:00:43,779 --> 00:00:44,419 OK. 14 00:00:44,889 --> 00:00:51,630 So we want to accept the user username and a password. So let's prompt them to do that. 15 00:00:51,639 --> 00:00:53,319 All right. So I'm gonna say username 16 00:00:54,340 --> 00:00:56,520 equals and now inputs 17 00:00:57,939 --> 00:01:03,400 in brackets, let's say enter a username 18 00:01:04,239 --> 00:01:05,180 colon. 19 00:01:05,379 --> 00:01:06,290 Ok. 20 00:01:06,709 --> 00:01:10,540 And then let us prompt them for the password as well. So password 21 00:01:10,919 --> 00:01:12,160 equals 22 00:01:12,559 --> 00:01:14,940 input and then in brackets 23 00:01:16,290 --> 00:01:19,190 enter a password 24 00:01:20,040 --> 00:01:22,370 colon and there you go. 25 00:01:22,690 --> 00:01:28,419 All right. So right now, once the user has provided the username and the password, 26 00:01:28,750 --> 00:01:36,160 we would like to store them in a file, we can call the file users dot TXT as an example. 27 00:01:36,169 --> 00:01:36,980 Ok. So 28 00:01:37,169 --> 00:01:38,849 what we're gonna do is 29 00:01:39,150 --> 00:01:41,989 we are going to say with 30 00:01:42,800 --> 00:01:47,569 and now open, remember we need this function to create our file. 31 00:01:47,750 --> 00:01:51,730 So now let us add the name of the file. I'm going to call it users 32 00:01:52,610 --> 00:01:53,720 dot txt. 33 00:01:54,360 --> 00:01:58,620 And now let us enable the append mode. 34 00:01:59,050 --> 00:02:00,500 So I'm gonna say a 35 00:02:00,860 --> 00:02:04,169 OK. And then as well as file 36 00:02:04,540 --> 00:02:05,500 colon. 37 00:02:06,019 --> 00:02:07,540 All right. And now 38 00:02:07,730 --> 00:02:11,419 we can use the right function. So I'll say file dot right. 39 00:02:12,199 --> 00:02:13,720 And now in brackets, 40 00:02:13,940 --> 00:02:15,809 we can use our F string. 41 00:02:16,449 --> 00:02:19,000 And then let us add a codes, 42 00:02:19,479 --> 00:02:21,470 color braces, user 43 00:02:21,639 --> 00:02:22,350 name. 44 00:02:23,330 --> 00:02:25,350 Let's close that. 45 00:02:26,100 --> 00:02:30,619 And then we can also add a column to separate the password from the username. 46 00:02:30,630 --> 00:02:31,820 So col braces again 47 00:02:32,149 --> 00:02:34,869 and then we can add a password. 48 00:02:35,389 --> 00:02:36,919 And then for good measure, 49 00:02:37,259 --> 00:02:39,119 we can do the 50 00:02:39,610 --> 00:02:42,320 uh backward slash and then n 51 00:02:42,589 --> 00:02:44,440 so that each user 52 00:02:45,880 --> 00:02:48,619 information will be stored on a separate line. 53 00:02:48,630 --> 00:02:50,889 Each user credential will be stored on a separate line 54 00:02:51,270 --> 00:02:52,979 and it is OK. 55 00:02:53,259 --> 00:02:55,619 All we gotta do right now is we can print out 56 00:02:56,490 --> 00:02:57,899 a simple message 57 00:02:58,449 --> 00:03:01,309 that would say something like print. And then we can say 58 00:03:01,910 --> 00:03:05,410 uh user registration 59 00:03:06,479 --> 00:03:08,139 was successful. 60 00:03:09,380 --> 00:03:10,119 OK. 61 00:03:10,889 --> 00:03:12,800 And there it is. OK. 62 00:03:13,009 --> 00:03:18,520 So how do we now integrate our registration function with the main function itself? 63 00:03:18,759 --> 00:03:21,199 What we're gonna do right now is we're going to come 64 00:03:21,210 --> 00:03:24,630 all the way right here and say if choice equals one, 65 00:03:25,020 --> 00:03:27,110 then we can remove this. 66 00:03:27,729 --> 00:03:30,119 We no longer need this print statement 67 00:03:30,369 --> 00:03:32,309 and we will just call the function and the 68 00:03:32,320 --> 00:03:35,589 function that we created here was what register on 69 00:03:36,149 --> 00:03:37,509 user. So right here, 70 00:03:37,789 --> 00:03:39,589 I'll just say register 71 00:03:40,179 --> 00:03:41,520 underscore user 72 00:03:42,110 --> 00:03:43,490 and then brackets 73 00:03:43,869 --> 00:03:46,880 and then there it is. So hopefully, 74 00:03:47,059 --> 00:03:51,190 uh this should work. Let's go ahead right now and test it. 75 00:03:51,199 --> 00:03:52,690 So I'm gonna run the program. 76 00:03:53,179 --> 00:03:53,970 Ok? 77 00:03:54,080 --> 00:03:57,880 Number one, we want to register press enter, enter, username. 78 00:03:57,889 --> 00:04:02,660 I'm going, I'm gonna go with Alex password. I'll just go with Alex again. Ok. 79 00:04:02,669 --> 00:04:03,729 Just for a test 80 00:04:04,100 --> 00:04:05,729 enter and ok, 81 00:04:06,490 --> 00:04:08,389 user registration was successful 82 00:04:08,500 --> 00:04:11,020 and we have our users dot TXT file in here 83 00:04:11,229 --> 00:04:16,309 and if I open it up, awesome. You can see it says Alex. Alex. So fantastic. 84 00:04:16,320 --> 00:04:20,559 We can see right now that it's actually working so far. So good. 85 00:04:20,670 --> 00:04:24,019 Join me in the next lesson where we will now create 86 00:04:24,029 --> 00:04:28,230 the function that will allow our users to log in.