Python 7.5 : Hierarchy

We will continue to improve our code this code is already better than what we had before but we can still improve it We can already see that the function is called 3 times and we will start by deleting it and creating a variable that we will call number of people equal to three knowing that we can change this value at any time depending on the program and here I will make a loop for for i in range I'm going to put number of people with a colon and inside I'm going to put i like this and now if we look at our return information function we see that this function does two things at once, it gets the information and it displays. And ... insofar as in the program we would like to display the information other than in the function return information it will be a little difficult, so we will create a function display information is the name def display info which takes as parameters the name and the age and inside we'll put this here we'll restart our code We already notice that we have name of the person 0 to improve that I'll put i plus 1 at the level of our loop i takes the value 0, therefore at the beginning of the program we'll have I'll put in comment 0 and now if I do return i+1 instead, we'll see that the person will take the value one, after the value 2, after the value 3 so I'll restart my code we see name of person one I'll put titi age of person one name of person 2 toto age of person 2, 45 name of person 3 titina person's age 3, 34 we have a problem in our code ah well it's because in the parameters we forgot to enter the number of people here I'm going to write down nb already and at this level we say that we haven't created the parameter person number so we have well at worst we can write down this person number comma and here I'm going to put person number like this, at this level I'm going to put person number here I'm going to call the function display information I'm going to pass the parameter person number, name and age here and here we can change the variables, we can name this person name person age person here I'm going to name person age person I'm going to relaunch my person code a titi age 34 you can see that the function display information is working well so our code is working normally I'm going to continue to enter the information touch age 23 it works age you can see that it works perfectly well as everything works normally we will see how to return several values in a function through the word return.