Hello, I’m Linda. Shangen and today. We are going to go through the arithmetic formatter on free code camp. I went through Python for everybody by myself is pretty easy. They have a video players to explain everything to you. So I didn’t think I would make a video on that, so I’m just going to move on to the Python projects. First one we have is the arithmetic formatter. Let’s look into this. And we can view the full project description and the starter code on rippleit, so just follow this link and then it will show what the challenge is. Just reload. If the Id is having trouble, there we go. I have it open. Uh, first of all, we want to look at the readme and we can click preview and it’ll show us the markdown on this page, so yes assignment is to make 235 plus 52 as a string become this, so it’s formatted up and down vertically instead of horizontal and we can also send it as an array and then it will become these four output like this inside the console, so kind of finicky, because we have to like, come up with all the spaces and come up with how long these dashes are going to be, and we have to check if it’s a plus or minus and make sure the everything’s in the correct order, and there’s no special characters, so let’s get started on this first of all. I’m going to go into the main Dot Pi and make sure we have it. We’re printing out an arithmetic arranger of these four expressions and also in here. We want to return. We want to turn this array right into into a string that looks like this, where we have the numbers and the new line and then more numbers and the pluses and minuses and then a new line and then the dashes. So yeah, we basically turn this into something. A weird looking string that in the console will look really nice. So the first thing I want to do is. I want to define some variables here. We’ll, go first equals an empty string. Second equals an empty string. Go lines equals an empty string and we’ll go sum. X equals an empty string and we’ll also go string equals an empty string and we’ll say for problem in problems, so we’re getting the problem list from problems and we’re going to loop through them. We’re going to say if I also want to import a package. I’m going to import re, which is the regular expression package for Python, and we’re just going to say ifreesearch and we’re gonna search for values that aren’t the space or white space zero through nine dot, plus or minus, and we’re gonna search for them in the problem like so, and so if that happens, then we’re going to return. Error numbers must only contain digits like that, and there’s another check. We have to do for like pluses and minuses, because right now we could pass in a multiplication or division, so I have to do another check with that. We’ll do if research, and we’re going to search for a division on the problem or re-do’t search for the multiplication on the problem, then we want to return error. Operator must be a plus or a minus so that will handle those and knowing problems, and then after that still inside this for loop, we can do first number equals problem dot split and we can split it by space and then grab the first part of that array, then, which will be the first number so that would be like 32 here and we can grab the operator that will be the second one so problem dot split from spaces and we’ll grab the second one, which would be index of one, and then the second number will be index of two and we’re getting this green squiggly line underneath because we’re not using these values right now, also with these ones. So then now I want to check. If length of the first number is greater than or equal to 5 or length of the second number is greater than or equal to five and we’re going to return. Error numbers cannot have more than four digits. So there we go next up, We’re going to do sum equals an empty string, so lots of different variables with this. We’re going to say if operator equals a plus and we’re going to do sum equals string and we’re going to have to parse our numbers, so we’ll go int first number and we’re going to add it to this into the second number and then turn it into string and that will be the sum and we’re going to say lf operator equals a minus sign, then kind of do the same thing except subtract it, so let’s say sum minus first number minus second number like so, we also need a another parameter up here, and that is the solve parameter and it’s an optional parameter, so we have to set a default for it. Its default will be false, but if someone passed in true to that value, then we would actually have to solve it like this right here. See, they have true here, and then we actually have to solve it as well, so that’s why we have to add this stuff in next up. Still inside this for loop, we’re going to say length equals Max of our length of our first number, compared to our second number to the length of the second number, we’re going to say top equals string of the first number dot R, just outside of that dot our just and we’re going to pass in the length bottom equals operator. Plus, the string of the second number dot are just length minus one, so yeah, lots of tweaking to get the spacing rate line equals an empty string and say res equals string sum dot R just of the length were going to say 4 s in range length. We want to add the dash marks, so we’re going to do line plus equals the dash and then outside of that for loop outside of this inner for loop. Still inside the outside for loop a little confusing there. If problem does not equal problems, the minus one means last character in that problem, so the last problem, then we just want to say first plus equals top plus a space, and I’ll just copy this part. It’s just so that we don’t add spaces to the last problem, so like here, there won’t be any spaces after 523 Otherwise, if we did it for this for all of them, then there would be spaces after 523 and we’re going to say if solve. So if we are going to solve it, then our string is going to equal first plus Backslash N for new line plus second plus Backslash N for new line again, plus lines plus Backslash N. Plus the sum X. And we’re going to say else it’s kind of the same thing as this, except minus the sum X and the new line there, and then we want to return the string at the end, so we’ll just do return string and we can get rid of this return to range problems. And, yeah, one other thing right at the start. We have to check. We have to check. If the length of problems is greater than 5 then there’s too many problems, so we’re going to say if the length of problems is greater than five, and we’re going to say, return error too many problems. And there we go lets. Uh, try running it. See what happens, all right. We got an error, lets. See what this error is. Line 19 all right. I forgot a angle bracket here. Okay, now, let’s try it, all right. We had two failures and the rest passed. It looks like lets. See what the two failures were. It’s so hard to read this stuff. So this one’s test arrangement and this one’s test solutions. You can check the test module, so this test arrangement one, so I must be off a little bit with my spaces and stuff in range length. Okay, that didn’t help Seems like the error handling is good. It’s just the formatting of the string like this doesn’t equal this, obviously because there’s three dashes here and one dash here. Okay, I have to add a plus to the two to the length. That’s what I have to do so that it will add more dashes right here and it will make the top and bottom a little nicer, so lets. Try running it now. Still failing. We’re not getting the dashes. It looks like, oh, we are for this one. Oh, maybe it’s because this stuff has to be outside of the indentation. So if I shift tab it over so that it’s outside of the loop and maybe it will work. Yeah, there we go, okay, so yeah. We just have to make the solve part outside of the the first for loop, which is the problems for loop, so yeah, Python’s a little annoying with that with the different indentations and stuff, but yeah, that was the problem, and now it ran the six tests and got it done, so it’s pretty cool. Uh, I got a lot of help from the forum for this one. So arithmetic Formatter forum help. So, yeah, I basically looked at what this guy was doing, especially for for getting the spaces, right and stuff like that because I thought it was really annoying to try and do that on my own so so, yeah, if you’re stuck, you can also look at this stuff, and they actually helped him out with a part on this by doing this. So yeah, pretty cool there next up next up. We have the time calculator, Which I did all by myself. No help from the forum, and it was pretty fun. So that’s what we have up next and I will see you next time. See ya!