'python dictionary remove duplicates with error of +-1
maybe someone can help me with this. I have a dictionary here:
print("levels: \n", SPYlvl)
{445: 8,
444: 6,
427: 6,
428: 4
}
I want to remove keys with numbers which is near +-1 in example: we have 428 which is repeated 4 times and we have 427 which is repeated 6 times
I would like to remove the 428 because it is +-1 of 427 and is repeated less.
the same with 445 an 444, I want only to leave 445 which is repeated more times.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|