But also, I have updated your post to place you code inside code blocks. So you can remove the underscores since the indentations will remain
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Can I explain how I think 3 or 2 == 4: works?
Not really… perhaps this is why I don’t understand.
Here’s what I see:
The line, ‘if 3 or 2 == 4:’ says to me, if the number 3 or 2 equivalates to the number 4 (which it does not)… then, the next part is like a command that follows.
In this particular case, I wrote the variable (sag_1) is equal to the string “six”. (ie., sag_1 = “six”).
But since 3 or 2 does not equivalate to 4, then… I assume the next line is read… until the elif statement works. And I was actually trying to figure out how it decided which if statement to prioritize (if it chose == 3, or == 2).
Obviously, I have a fundamental misunderstanding that I need help to clarify, and I don’t even know where to start looking for help (yes, I tried googling where to look for help with python).
I’m still grappling with the fundamentals while working to build an arithmetic formulator.
Yes, the gas and gaso functions were just practice to check my understanding, but it was also related to putting dashes at the bottom of each problem (in the arithmetic formulator)… I presume the dashes must match the width of the problem… which depends the length of the addends.
I wanted to check how a def function would return in a situation where multiple elifs were “true” ( true by my logic… lol) and whether and how the order of the if/elif statements mattered (if == 1, elif == 2… vs if == 4, elif == 3…)
My actual code (now, thanks to your help) looks like this:
So, I finished my arithmetic formatter project today, and it works perfecly in pycharm, but it doesn’t pass the camp test.
I was wondering if I could run it past you or anyone that works for freecodecamp, to get some feedback.
I’m pretty happy with it, even though (full disclosure) I know it’s far from elegant (and probably not even close to what was expected). There’s like a thousand lines of code here… but like I said, it works perfectly in pycharm.
JeremyLT,
There’s really no “fixing” it- it’s 1053 lines. I looked around and saw other arithmetic formatter codes are typically less than 50 lines (nice!). So, it would be like fixing a battle ship by making a canoe out of a tarp.
I will continue to learn, of course, and will test other codes later, but this thing that I created is done.
Refactoring code to meet the same functionality while being simpler, clearer, and more maintainable is a very important on the job skill. I understand not wanting to do it, but you’re definitely abandoning a opportunity to build critical professional programming skills.