Answers for "python dictionary key in range"

0

python dictionary key in range

myDict = {
	(float('-inf'), 12): "child",
    (13, 19): "teen",
    (20, 65): "adult",
    (66, float("inf")): "senior"
}

testValue = 10

for (k1, k2) in myDict:
    if (k1 < testValue and k2 > testValue):
         result = myDict[(k1,k2)]
Posted by: Guest on October-01-2020

Code answers related to "python dictionary key in range"

Python Answers by Framework

Browse Popular Code Answers by Language