Python Gradebook

Hello, world! Can anyone tell me if my code needs any change? I am not sure if I’m wrong or correct, I followed all the instructions and done from step 1 to 10. All feedbacks are appreciated, thanks in advance.

Here is my code →

1 Like

I looked at this code and thought, “Huh, this is slightly different than I remember the project being.” So I went back to look at mine, and found that they’ve changed the project since I did it! I’ll finish up the new version of the project and come back. :sweat_smile: At first glance, though, it looks pretty good!

3 Likes

One thing, step 8, when you have to remove the value from the sublist `[Poetry’, 85].

You have this:

gradebook.remove(["Poetry", 85])
# print(gradebook)

gradebook.append(["Poetry", "Pass"])

But, that’s not what the questions asks.
You have to access the sublist and remove the value. You already know that ‘Poetry’ exists at index [2], so…it would be:

gradebook[2].remove(value)

And then with Step 9 to append “Pass” to that sublist, you have:
gradebook.append(["Poetry", "Pass"])

Which is fine…But, you need to just append the “Pass” value to that sublist. So, how would you do that? It’s similar to step 8. You’re still accessing index [2] and then appending the new value. LMK if that makes sense.

2 Likes

Thank you for reviewing, I have changed my solution.

My code →

1 Like

This updated code looks like mine (though I did positive index values instead of negative ones), so we’re probably both good to go! :+1:

2 Likes

I had also got to this solution.

However, I was wondering whether it would be possible to add two lists together to generate a 2D list?

So instead of:

gradebook = [subjects],[grades]
print(gradebook)

([['physics', 'calculus', 'poetry', 'history']], [[98, 97, 85, 88]])

Having:

['physics',98],['calculus',97],['poetry',85],['history',88]

There aren’t any simple built-ins for this but various forms of iteration should be able to get you this output without too much work. I think loops are introduced fairly soon on this course which would provide you with the tools you need to get that output.

1 Like

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