Willdomybest18
Willdomybest18

Reputation: 137

median confusion to use key or value python

This is very basic. If I have the following:

{key  :  value}
'age20' = 10
'age21' = 10
'age22' = 12
'age23' = 12
'age24' = 40

Do we use the median as the key? So this would be 'age22' or do we use the value? So its 'age23'.

Thanks.

Upvotes: 0

Views: 33

Answers (1)

KokoEfraim
KokoEfraim

Reputation: 327

Use the value. Median is a value which in your case is 12. If we use python set as analogy, I believe it is better to use the first occurrence as the key, which is ‘age22’.

But frankly your question is too broad, and the objective is obscure, the best practice is never to assume. The python zen: Explicit is better than implicit, should be referred.

Upvotes: 1

Related Questions