Jupyter Notebook NameError issue

Hello everyone,
I am currently working on the “Analyzing financial data with Python” skill path and am in the middle of the “Bank Teller” project.

On question 5, we are asked to create a function that will take care of depositing money into the proper account and output a string with the updated information. Then on question 6 we are asked to call the function with a few parameters. — The issue I am running into is that when I try calling the function on question 6, I am hit with a NameError that one of the parameters hasn’t been defined - If I am to understand this correctly, its as if jupyter notebook isnt even reading the function from question 5 on the cell in question 6?

I have uploaded the project to GitHub so that you can see the code and questions yourselves but any help here in finding a solution here would be super helpful!

I have already looked at the solutions notebook for this project and even copy/pasted all the code when I got sick of trying and it’s still not working out. Any idea what the issue might be???

that is not the problem. You seem to struggle with parameters and arguments. When we create a function, we can give the function a parameter:

def example(par):

then we we call the function, we need to provide an argument/value for the parameter:

example("hello world")

now, we will see hello world printed.

The argument can also be a variable:

def example(par):

x = "hello world"

but then this variable (x in the example) needs to be defined, otherwise, you get a NameError

understanding the relation between parameters and arguments is crucial.


But the checking_balance and savings_balance are already defined. Its was the first thing I defined in the challenge as 0. each time I pass checking_balance and savings_balance into the function call as an argument it should already be defined no?

If I am still not grasping the concept here I’d appreciate some articles or even a codecademy lesson that digs deeper into this please

Not much experience with jupyter notebook, but it would make sense that you could use variable from earlier steps?

If you’ve reset a session then make sure you run all the previous cells in order to make sure the variables are actually created in your current ipython kernel. Whilst the text might be saved from a previous session the segments of code aren’t necessarily run automatically. There should be a shortcut in the menu to run all code cells (or run the ones you need one by one, in the necessary order).


Thanks for the response…I decided to take a few days break to refresh and turned into a couple of weeks. I will hop back on and see if its still an issue I can’t solve but I will try running all the code cells together as opposed to one by one like I have been. hopefully I can figure it out!

In Learn Python/Loops/Reggie’s Linear Regression Project. Hi, I am having an issue with opening the task on Jupyter Notebook with my windows device. Whenever I click on the file to open it on the browser, I am greeted with a frustrating message that says "Error! C:\Users\Laptop 4\Downloads\Reggie’s Linear Regression zip is not UTF - 8 encoded
Saving Disabled.
Its been days, I want to complete my exercise can someone please give me some tips.

It seems like you’re trying to directly open the .zip file which is a compressed file that cannot be immediately accessed by Jupyter Notebook. Extract the contents of the file first (a right click should give you that option) which should create a directory or two containing a few files. You want to open the ipython notebook files which would end in the .ipynb extension.

Thank you very much. I am having an issue in the last part of the current exercise. I don’t know what to do. I feel like I have tried everything. In the second to last instruction of the exercise it asks us to find the smallest error through trial and error. We have to use a loop to find the smallest error and we are supposed to compare the result of the function above to the variable smallest_error.

The instructions say:

  • smallest_error — this should start at infinity ( float("inf") ) so that any error we get at first will be smaller than our value of smallest_error

But when i enter smallest_error = float(“inf”) as the exercise suggests, the program throws back a type error saying that I cannot compare the integer value of the function above with the variable smallest_error because you cannot use “<” between a int and a function. I tried to declare smallest_error as infinite in so many other ways but no success. It keeps recognizing it as a function.

smallest_error = float(“inf”)
best_m = 0
best_b = 0
total_error = int(calculate_all_error(m,b,datapoints))
for m in possible_ms:
for b in possible_bs:
if total_error < smallest_error:
best_m = m
best_b = b
smallest_error = calculate_all_error
print(best_m, best_b, smallest_error)
This is my code.

I believe your error is more directly related to this line: smallest_error = calculate_all_error. From previous lines I imagine that calculate_all_error is a function so you’re just assigning another name to this function. You want to call this function instead like the following- calculate_all_error(arg1, arg2, ...) but make sure to pass the correct arguments.