Assignment code wouldnt work no matter what!

I’m stuck in the last assignment of the scientific calculations with python course. The code doesn’t pass the experiment function test no matter what I do. It is just one error. It would mean a lot if anyone could help me understand why it doesn’t work and what could be done for it to pass the test.
Assignment 5 code

Hey! Glad you posted this, I had a lot of fun digging into it. I forked your code, and was able to fix the issue.

The error you are seeing from the test is caused by the way you are comparing the dictionaries for the expected balls and randomly picked balls in the experiment function:
val = expected_balls.items() <= dict_pick_list.items()

The method .items() doesn’t take into account the order of the items in the dictionary, so you can’t guarantee that the comparison is between like items. For example, this code could be comparing the number of green balls to red balls. To solve this, you’ll need to directly compare like items. :slight_smile:

There’s also an issue with the 3rd test that you’ll see after you fix the 2nd test that’s related to the ball function.

I also forked your code if you want to see how I solved it:

Good luck!

Hey! Thank you very much for your help, it means a lot. That was the error that was holding me back from submitting the assignment and successfully finishing the course. I am truly grateful to you for choosing to help me on this. Cheers!

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