Python 2.12 : Improve our program with the loop
Well, we're going to delete all this to improve our program I'm going to delete and uncomment our starting code here we want to make a white loop that is to say as long as the age is not correct we'll restart each time the age to the user and until there is a trick. the program will continue to run here We'll start by initializing the age pro next here equal to 0 and each time we restart the age of the people made me a while loop as long as the next age is equal to 0 two points you ask again the age we will put this code if inside tab we'll try to comment it out and display a printout at the end of the loop I'm going to run my program: What's your name? toto What's your age? 23 I'm going to put in the loop but I'm going to launch anything here I'm going to put in Toto, the age I'm going to put in anything we see that it enters in the loop and it me that the entered age is not correct and it restarts age to every time. If I have something whatever it will ask me until I enter a correct age it will continue to execute the program like this end of the loop now I will delete this I will uncomment this to be able to execute Here we are going to improve our program instead we are going to declare the age age here as age and here we'll put age str because this is a concatenated age put str here we'll say age takes age str and we delete this here age str even works this age plus one normally we'll execute to see what's your name? toto, what's your age? it normally works everything works well I'll reexecute my code and enter anything Toto on name, age it hurts me every time until I enter the correct age and it comes out of my loop it comes out and it says your name is Toto and you are 34 years old next year you will be 35. Well, we'll see you soon on the next video on the while loop lifeline.