Python 7.4 : Refactoring our code
We will continue our learning and here we will see the refactoring of the code I added this piece of code in our program and we are going to refactor it to better understand what it is used for this way of doing things is not forbidden the problem with this move is that it is not adaptable nor maintainable for big projects if we look well at our code, we are going to notice that it is the variable names that change and the age and also the number of the person we will make a function to improve our program we'll name the function return information which will take a parameter the number of people and we'll use as a variable the name and the age def return information and it takes as a parameter the number of people inside I'll copy this code I'll delete that and here I'll add characters we've done that the function print took several variable of different nature what is not the case the function input but here we'll add the characters the input function but here to add the name of the person we're going to do a concatenation so I'm going to put percentage s at this level and outside I'm going to do a percentage person number I'm going to do the same thing here percentage s and outside percentage s before launching we're going to put this code as a comment like this and if I'm going to call my function I'll put I call I put 2, I put 3 I run my code again you see that at this level, we have name of person 1 the age of person 1, I add 12 name of person 2 anne the age of person 2, 23 here we have an error I will correct that by putting a comma, I will put comma, like this I raise, titi age 12 annema 23, you see that it puts the person well, we continue, totino 34 it puts well the person 3, therefore they are 3 everything functions normally and we say to ourselves very soon for a next video, concerning the hierarchy.