Python 8.3: Refactoring code

We will continue with our questionnaire, and the objective here is to refactor our code, we will do this through an exercise and for this I invite you to make a function that we will name ask question and to put the parameters we will ask at this level the difference between the two questions is ? and to answer this, we see that it is at the level of the numbering we have question one and question 2, so here we will put question then, we're going to answer with answers either a, b or c, or d, so we're going to put answer 1 comma, answer 2 comma, answer 3 comma, answer 4 comma, and the answer in question and now what are we missing ? it's just the answer so we'll have to find the right answer, we'll name this choice answer like this and this choice will take the right answer if it's a, if it's b, if it's c, if it's d, there's no problem now so we'll try to implement the so we're going to try to implement this function before that I'm going to put here a def that I'm going to name question 2 I'm doing the same thing here I've done this so that you can see the difference between what we're going to do now and what we did earlier and here I've called two functions which means that if we had 10 to 100 in question we had to do the same thing like do the function of question one, the function of question 2, the function of question 3 see up to question 10 or and that can be really penibble and that's why we have think about doing this what we're doing now refactoring the code, well now we're going to implement Our function and I invite you to do it and we'll meet in a few minutes for the correction. About the correction We will start by copying this def I paste like this colon And at this level I'm going to copy this code that I paste down here in our start function and I'm going to delete this I delete all of this at this level I put question, here I put r1 r2 r3 r I check here I'll put choice answer like this you're going to call the function in question by doing question, the question is what? What is the capital of France? I put a comma I copy the first answer I copy the second answer I copy the third, I put inside and I make a comma and the fourth answer I put a comma to put the good answer which is here c and I throw my code you see that it is displayed normally If I put a, bad answer I raise I put b wrong answer I raise I put c right answer our code works normally as there are two questions at the beginning I will copy this I paste at the bottom here I put question 2 capital of Italy And here I change the data a we have Rome b we have Venice c we have Florence, for d we have Pisa and the good answer here is a, I raise I put c The question which follows is displayed directly, I put a, good answer well we can make our code differently, putting at this level a space and at the top I'm going to make another print, and inside I'm going to put question in capital letters, here I'm going to put a plus and at this level I'm going to put two ribs, I'm putting a plus I'm doing the same thing two ribs inside I'm putting a I'm cutting a, I'm cutting I'm cutting b I'm putting c I cut I put d and I'm going to delete this I delete the question too that makes our code more aesthetic already and we have to reassure you at the level of the answer as here we put c we have to count ABC and we fall well on Paris which is at the level c and we put the answer so you have to be concentrated when you do this because you can run into I restart my code, I put c and I put a, the code works totally, there is no ... We can now delete this and as we said at the beginning that it was three questions you can add another question and do the same thing so you understood the concert and that's all for this video we'll see you next time for a video about the core.