Mar-26-2020, 07:11 PM
Given any random dictionary (or a list doesnt matter), how to ask the dictionary if there is an unique value (so which only occurs once).
{
"1": "a",
"2": "b",
"1": "c",
"1": "c",
"1": "33",
"1": "a"
}
--> No unique value is found ... or technically 2 (b and 33) are found, but I only want 1.
so not desired result ... therefor errorhandling or so.
{
"1": "a",
"2": "b",
"1": "c",
"1": "c",
"1": "c",
"1": "a"
}
--> Unique value is found (b) ... do something.
What would your approach be?
Set returns all unique values but I'm not after that.
{
"1": "a",
"2": "b",
"1": "c",
"1": "c",
"1": "33",
"1": "a"
}
--> No unique value is found ... or technically 2 (b and 33) are found, but I only want 1.
so not desired result ... therefor errorhandling or so.
{
"1": "a",
"2": "b",
"1": "c",
"1": "c",
"1": "c",
"1": "a"
}
--> Unique value is found (b) ... do something.
What would your approach be?
Set returns all unique values but I'm not after that.