We've come a long way to get here, so let's quickly rattle off what we know so far. We know that we need to process the events to generate a report. We know how to sort the list of events chronologically. We know that we'll store the data in a dictionary of sets, which we'll use to keep track of who's logged in where, and that we'll have a function that generates the dictionary and a separate one that prints the dictionary. I think that's everything. Know what that means? We're finally ready to write our code. Here we go. Let's start by defining the helper function that we'll use to sort the list. We'll use this simple function as the parameter to the sort function to sort the list. Now, we're ready to start coding are processing function, which we will call current users. The first step is to define the function. Inside the function, we'll first sort our events by using the sort method, and passing the function we just created as the key. Now, before we start iterating through our list of events, we need to create the dictionary where we will store the names end users of a machine. Now, we're ready to iterate through our list of events. Next, we want to check if the machine affected by this event is in the dictionary. If it's not, we'll add it with an empty set as the value. Now, for the login events, we want to add the user to the list, and for the logout events, we want to remove users from the list. To do this, we're going to use the add and remove methods, which add and remove elements from a set. Once we are done iterating through the list of events, the dictionary will contain all machines we've seen as keys. With a set containing the current users of the machines as the values, this function returns the dictionary. We'll handle printing in a different function. Nice. We now have the dictionary ready, and we need to print it. For that, we'll create a new function called generate-report. In our report, we want to iterate over the keys and values in the dictionary. To do that, we'll use the method items that returns both the key and the value for each pair in the dictionary. Now, before we print anything, we want to ensure that we don't print any machines where nobody is currently logged in. This could happen if a user logged in and then logged out. To avoid that, we tell the computer only to print when the set of users has more than zero elements. Now, we said earlier that we want to print the machine name, followed by the users logged into the machine, separated by commas. Let's generate the string of logged in users for that machine using the method join. Now, we can generate the string we want using the format method Yeah, we've written all the functions we need to tackle our problem. Did everything makes sense? This is a great moment to pause and review the videos for each step in our approach, from problem statement to writing the code. Make sure it's clear, not just which function we're using, but why we're using it. If anything is a little fuzzy, remember the discussion forums are always there for you to ask for help. It's about to get exciting in the next video. We're going to execute this code and see if it works. I'm feeling good about it. Let's put our code to the test.