 All right, hello, this is Christian. So in this video tutorial, we're going to create a list of user objects that will look something like this list here. Okay, so it's a collection of user object. Now the user data will be something like this one here. So this is a list of user dictionaries, right? So this is one dictionary here and so forth, I have five user data here. So they did data here, actually I just basically pull from this text file and basically copy this first five here and then build it into a user data dictionary and then we're going to convert this into an object using a class called user, right? So this is the idea here. So first thing I'm going to do is go over here and we'll create a new file and I want to say this as a user.py. This will be the user file for the class. So I'm going to up here and create a class called user and we need the init function with the ID for the user underscore ID, first, last and then email. So if the user is equal to user ID. Okay, so I also like you to build your own setters and getters as well. So this would be like the setters, methods, very simple. If you get user ID, you need to self in here and well, actually this would be the setter, okay? So setter needs set, we did the user ID I'll make it really short. So I'll just go one liner here. Just basically set the user ID, user ID, okay? And this would be the, not del, should be that definition. Set first, last, set email. Okay, so that's all my setters and then also new my getters, but we similar except we call it get user ID. Okay, this is just the self and we're going to return self.user ID. And you see the pattern here, right? So get first, and then return first, return self first. The reason why you create getters setters is usually because you don't want to access the data fields directly from the object. So usually, you know, you want to use functions so that you can have more control. Okay, so that is my user class. And once we test it, we'll see if it has any errors. The next thing is we want to import both of the user class and the user data here. I already created this object into the main program over here. So that's, I wonder, first let's do a import from the user file, import the user class, capital U. And the other one is, you know, you can do it this way or you can also import everything in the user file. So you can also do this way from user data, import the user here is fine. Or sometimes you can put like star here, like that. You know, it's a well card, but well card means everything, right? So just put user here is fine. All right, so that's my import. Let's create a main function. Okay, let's invoke it out here before we forget. At the bottom, right? So what do we need, right? So the user has those fields. And what I'm gonna do is I'm going to read each of those, you know, data from the user and we're gonna create a user, a user's list just like this. So first let's create a list user list, we empty list first, okay? And then now I'm gonna go through that list of users. So we say for every user, for every key and value, I taught you before this one key value pair, every key value in the users.items, okay? That will pull both the key and value fields. That means it's gonna grab both the ID for the key value for the value here. So go through every field here. Actually, I didn't do it correctly. This is an individual object. So I need to do one more thing. Before I do that, I would say for every user and the users and then for every key and the user items, okay? Because the user here is the dictionary, right? So the user here is referring to, again, the one I highlighted here for every user a poll that I was the dictionary and then go every field value from that and you pull that up, right? That's another way you can do. I mean, lots of ways to do this. Maybe I'm not gonna do this way. This look confusing, so let's just do that. Sorry. The user is that one. So I'm gonna build a list. I do really easy way first. So I need to get the user ID from the user dot user or user ID, okay? That's what I call, what do I call it? It's called ID, oh, just dot ID. Not just the ID, not user ID. I'll call it that. And then I have the first is equal to user of the first, pass, finally you name the bracket, not the credits. All right, so that is my actual fields. I get that I put it on fields and then now you have a couple of options, right? So one is if you look at this over here, you can invoke the constructor and pass this data directly to it to create each user object or you can also call the set and you pass the username personally in the individual field this way. So this way you can do either way. So this example, I'm going to use the constructor to create the new object that way. Since I already have my fields here, right? So I'm going to put like a new user, I've got a user here for now. It's going to be the user, pass and the user ID, first, last, email. And that will create that first user into the user object, right? If you want to see what that looks like, you can print it out, of course, but and that's going to you're not going to see anything here, okay? You just see a user object, which is not really helpful. But let's say I want to print that out so you can see it, you know what to do it later. So every user, when you get the user, so this is called the user instantiation character here, user object instantiation. You create an object of user, get this information, put that to user and then we're going to add or push this user to the user list up here, right? So you just basically do user list, that append, let's say let's push the user into the list and then we've got the word done. So it goes back to the next user, repeats, grab the data, build the object, pass to that, you keep building the user list, right? So finally you're going to print it out, right? So here, before we do that, I want to just show you what it looks like and the console over here. So to make it work, we have to make a global variable here. So all you do is instead of function because you can put it to global, to do that, you use global user list, okay? You put that on the top first and then you can use it in a program or in a function and then this will be hoisted out to the global space, becomes a global variable, okay? Now don't do this all the time but if you want to test it out, see what the data looks like, you do this way. So let's see if I go here in the terminal and run the program and we see what's like. So if you run, you should see the user list over here. If it's all correct, right? You can see that we have a users. These users, this user list here, initially it was, actually, did we do something? User list, yeah, it's empty, okay, that didn't do it, right? Let's see, for every user and users, we add that there, you push it to the user and it's empty, oh, error, too many emails. Save that, try again, by the way, it shouldn't be empty. Oh, come on, let's clear this. Okay, just write it, here we go. So we have our user list of five fives. You can see we're moving from the dictionary, right, to a list of object, user, user, user here. So if you open that, you're not gonna see the information because it's a user object. If you drill down, you will see the information, right? So here's the first name, email, here, and then the get-in-setters all here. Right, so that's how you build a list of users inside from a dictionary to a user object. So from the on, you just basically print them out, okay? So to print them out, we can go over here and we say for every user in the user list, so now it's a list of object as opposed to a dictionary, right? So you wanna print, I'll use the format, print the user that, as you can see the user ID, right? Those are the few that you wanna get, but we don't wanna go, I don't wanna use that way, I wanna use their function. So we'll call the user get user ID, and I get that one there, and then next is gonna be user.get first, and then comma, oops, I don't have too many curlies there. Each of those should be wrapped in a curly, right? We learned that before. And let's use the multi-line, it's easier to see. No, why don't we do it? Okay, that's fine. User.get last, close that, and then finally user.getemail, okay? And that will look something like that. And if you want multi-line, I think you have to use like the triple, if it lets me use a triple, okay? Instead of the single quote, you should use a triple quote. So that way you can break into multi-line like this. It's easier to see this way than a single line, right? So that's your print statement. And we'll see if you print that outside over here in the console, and here we go. So here is our data, printed out over here, one by one, five of them, okay? And that's how you use that. And finally, like I always showed you guys to do this, is break is a two function. So up here, you can go and refactor your code. I use a function called, I get users here, and I'm going to just basically remove this. I should copy this whole thing here, cut that up, put it inside here, and we're gonna return the user. So return user list, okay? So that means my user list over here will be user list is equal to end users. Okay, so I got my user, and then finally that's the print function. So again, the print user list, and then you move this whole thing inside here. And what does it need? It needs that user list, so I need to put that inside here. So again, I'm gonna turn this off. The reason why this works is because this become global, right? So we don't want that. I just put it here so you can see it, but normally you don't put that in global space. And then now you see that this is yelling on me, he said, hey, I need the user list, okay? So then you put that inside the parentheses here, and now you call the print function down here. You just pass the user to it, and user list. And there we go. We have you get input, and your output processing is not in here, but that is the way to do this. Again, save and run. And here is our data, looks just like before. Okay, so that is how you do it. I skipped the part where you read the data from the text file. You could read a text file here, the line by line, you know, do that, and extract each line, build the object like you see here, right? Build to object first, or how we do it, and then basically push that to your list, and build the list this way. So this is how you add object to a list. Thank you.