Error in Assignment code (Lunar Lander)

So I passed all the test but I keep getting this error (attached) in input 16 which is code that originated with the assignment. But it’s affecting the assignment grade despite passing all the tests. I can see that it’s a tuple error I’m not able to dig through. I’m not sure how to fix or circumvent that? Any help

I’m sharing the code from input 16 (not my code…came with the assignment) as well as the error below. Thanks in advance

Hi @Gard,

Let’s understand the error. It says tuple has no certain attribute, then we find which variable is trying to call that attribute. The answer is optimizer. Then we need to ask ourselves whether optimizer is supposed to be a tuple? The answer is no. it is part of your exericse 1 to define optimizer so I will not tell you what it should be.

I have the following suggestions:

  1. read exercise 1’s description to understand what is required for optimizer
  2. make sure optimizer is defined once and ONLY once
  3. on the jupyter notebook, click “Kernel” > “Restart”, and then run your notebook from the first cell to the problematic cell in question

I also suggest you to understand the error yourself, and use the print function to print out any questionable variable for your inspection.


1 Like

Thanks much Raymond for the insight!
I’ll look into!

Sure. Please do print optimizer and inspect it. If it is a tuple, then it is not what the exercise requires, or you have done the exercise correcly but somehow redefined it unintentionally. In the later case, you can spot the problem by searching through the notebook with the keyword “optimizer”, and if you can’t spot it being redefined, then my 3rd suggestion should make things right.

1 Like

Oh, @Gard I have one little suggestion for you on what to check, if you add a comma like the example below, you can change an integer variable into a tuple, so be careful about the commas.

x = 1 # x is an integer
x = 1, # x is a tuple
1 Like

Got it!! Thank you again!!