Build an Arithmetic Formatter Project

Ik this might sound dumb guys but I am very new to python and I think I have a genreal idea on how to complete this project but I am puzzeled by the begginign. I odnt know what to assign to problems? would it be an input asking the user to enter problems? https://www.freecodecamp.org/learn/scientific-computing-with-python/build-an-arithmetic-formatter-project/build-an-arithmetic-formatter-project

def arithmetic_arranger(problems, show_answers=False):
    problems = 

    return problems

print(f'\n{arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])}')

problems is the name of one of the parameters for arithmetic_arranger.
It will be passed to the function by the testing module.
(it is essentially an array of strings as can be seen in the startup code for this)

print(f'\n{arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])}')

so when I am creating this function should I use the numbers in the list to add and subtract? would would I put, like lets say I wanted to say add _ to _, what would those blanks be thats where I am mostly confused.

yes you need to add or subtract the given numbers.

I’m not sure I understood the rest of your question so please rephrase if you need an answer.

no I started to understand, but what do i assign problems to? would i put it to a list or what, because i kinda know what to do now but it says problem is not defined

wait I might be undertsanding this wrong, to change the function you would have to switch it in the definition of the function? so i would set problems equal to ([β€œ32 + 698”, β€œ3801 - 2”, β€œ45 + 43”, β€œ123 + 49”] right? So when I call the function I can just use problem as a parameter and if i want to change values change it in the function itself?

you don’t need to assign problems to anything. It is an array that is given to the function and you should just use the array as it is given (unless you need to make a copy of it or something then in that case, you will need to write code to do that).

So just use the parameters that are passed in to solve the problem.

yeah i kinda understand what your saying now I should give this value in the function [β€œ32 + 698”, β€œ3801 - 2”, β€œ45 + 43”, β€œ123 + 49”] (or whatever value I wanted to give later on) and just call the function with the parameters of problem which would already give it the values?

yes that is how parameters work. Functions are defined with the parameters so that we can call them later and give specific arguments to them.
They gave you an example in the code:

This is calling arithmetic_arranger and it is passing in the list

1 Like

I had another question, can i remove the print call at the end and just call the function? sorry I am new so sorry for the barrage of questions.

You can remove the print call but just remember to reset the code at the end before you try to submit.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.