Okay, now our program is completed.
Okay, but for learning Python, for understanding the Python better, I can use another way or another
thing to create this part.
Okay.
Improve this.
For example right here we're just using lists but I can use dictionary okay.
So it is just for better understanding of dictionaries.
So let's remove this part okay I will just remove it or I can comment this or I will remove it okay.
So here.
First we need to create an empty list.
And then for each time that it is reading or getting a packet, we need to add that packet to the list.
And it will create a dictionary for me.
And later I can use dictionaries.
Dictionaries has keys and values and I can use keys and values to print the result.
Okay.
Very easy.
Let's do that.
Okay.
So here I am inside this function, which is called scan.
I'm going to create a new list.
Let's name it client underscore list.
Okay.
So it is going to be an empty list right now.
Okay.
Let's use for loop A for loop here.
Okay.
Element.
Element in we had answered.
Okay.
In answer.
Do you know that this answer variable is a list right now okay.
So here I need to create two things.
Okay.
For at least one thing we are going to have the IP and also the Mac.
So let's create a dictionary here.
Okay.
It's going to be client dictionary I'm going to name it client dict.
It is equal to a dictionary.
So this dictionary has a key with the key is going to be IP and it has a value.
So the value is going to be for this one is going to be element okay.
Dot the IP which is p.s.r.c.
And also we have the Mac address.
Okay.
This is going to be the key.
And the value for Mac address is going to be element.
One dot h w is r c which is going to be hardware source for the Mac address.
Okay now I have the client dictionary.
And for each loop for each time that it is, uh, reading the packet.
I need to add these to the list.
So how can I do that?
List has a function called append.
So let's use that.
Okay.
We have clients list.
Then let's use the function that it has.
It calls append.
This append will add okay this to the list for each of a loop for each time that it is getting a packet.
So and then give the client dictionary okay for the first time it will come and read the element from
the answer list.
Okay.
And then it will append that to the client list which is here okay.
And then it come to read the second packet the third packet fourth packet and all the packet okay.
So when it is finished you need to return that.
So let's return it okay.
Return client list.
Okay, so now it is the first function that is doing its job.
And you need to create another function to print the result.
So let's create a function named print underscore result.
Okay.
So this is going to get uh something.
Let's name it result list is going to be an argument okay.
So here we need to print the IP mac address.
And then going to the next line.
And like that the thing that we have done it before okay we have IP okay at least three tab.
And then what Mac address.
Okay Mac address.
And then go to a new line which is backslash n and something like this.
Okay.
Now it is the header okay.
The header is completed.
So now it is time to print the IP and the Mac address itself.
So how can we do that.
Again I'm going to use a for loop.
Or I'm going to create a new variable called client.
For client in we have the result list okay.
And here I'm going to print that.
So now this client is a dictionary.
And here I'm going to print the IP for this and concatenate this with at least two tab.
And again the Mac address.
Okay.
And.
finished.
Okay, so now it is time to.
To call those functions.
Okay.
So here we have the scan function.
Okay.
And as you see we have the result list here.
We need to, uh store this scan function into a variable.
I'm going to name it scan result.
Okay.
So let's use scan.
Underscore result is equal to this one.
And then I am calling the print result function.
And then giving it the scan result.
And I think now it is completed.
If I come back right here and re-execute this providing the password which is Collie and waiting a moment,
you're seeing that we are having the same result this time with dictionary.
I want to add a little some more of this dot.
Okay.
So it looks more beautiful now.
I think it is better.
So here you learn how to use one function using list.
And also you learn how to use dictionaries okay.
You create this program.
And here we use two function to do this.
So thanks for watching.
And this section is completed.
You created your network scanner and it is completed.
It's working for all network.
Okay.
No matter if it is wired or wireless or Wi-Fi or anything, it is going to work for all networks.
So for me it is a virtual network and wired.
So thanks for watching and I will see you in the next section.