Passed all tests but getting weird error when submitting

Passed all tests for both exercises but getting weird error when submitting

The error I got: Cell #8. Can’t compile the student’s code. Error: AttributeError(“‘tuple’ object has no attribute ‘shape’”)

[Code Removed from Moderator]

Can someone please help? Thanks!

First of all you should not post solution code in the forum.

The error means that a tuple has no shape property, you are trying to do tuple.shape (whatever the name of the tuple is), that cannot work because tuple is not a list. It could work with list.shape. Instead to find the size of the tuple you can use len(tuple).

Hi Spah,

Sorry for posting the code directly.

However, the shape property wasn’t my code but was pre-written already. I’m new to python so would you kindly suggest how to fix it quickly?

The only place that uses ‘shape’ is m = x.shape[0]

Thanks a lot~


Sometimes the grader can be sensitive to changes you might have inadvertently made to the assignment by moving lines around or accidentally editing a cell or portion of the code that was pre-written. To eliminate that as a possibility, one thing you can try is:

Download a new copy of the assignment and move your exercise code there.

Run all the cells in your new copy of the assignment to make sure it works fine for you, then submit again to see if the grader likes the new version

It’s a bit of a pain to have to copy your exercise code into a new copy, but it can end up being a lot simpler than trying to track down some subtle thing you inadvertently edited in the original assignment.

If you’re still seeing a problem with the new copy of the assignment, feel free to DM me a copy of your assignment and I’ll take a look to see if I can tell where the problem is.

1 Like

Hi @Wendy,

Thanks so much for the suggestion!

I tried to revert the code base to initial and added my code back. It worked!

Apologize for the late reply here as I was busy with some personal work. I hope you’ll have a nice week:)


1 Like