#๐Ÿ”’ Help with sorting(and deleting) in dictionary

18 messages ยท Page 1 of 1 (latest)

foggy plaza
#

Is there a way on how I can remove two subjects from the main one? This is probably one of the most basic stuff but I am still very much confused

steep pendantBOT
#

@foggy plaza

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

rancid needle
foggy plaza
#

That is what I am trying to figure out. Where and how to put it

rancid needle
#

!e

d = { 'a': 1, 'b': 2 }
del d['b']
print(d)
steep pendantBOT
foggy plaza
hazy vapor
foggy plaza
#

What I'm trying to create here is a sort of ranking list.

Like:

Science:
Students 1-10

Math:
Students 1-10

History:
Students 1-10

#

It has to be 10 students and 3 subjects specifically

rancid needle
#

Do you mean you just want to limit what gets printed out when showing the sorted rankings?

foggy plaza
#

Yes

rancid needle
#

You could just map over sd to reformat the data.

#

Like:

#

!e

sd = [('Name1', {'History': 10, 'Math': 20}), ('Name2', {'History': 30, 'Math': 40})]
formatted = [f"{name}: {grades['Math']}" for (name, grades) in sd]
print(formatted)
steep pendantBOT
steep pendantBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.