I'm not entirely sure of the scope of your project. In the case that the example you included is simple in comparison to your project, what I would suggest is looking into JSON.
Selecting random values from a json file
Retrieving key, value of json data python
JSON is great for stuff like this. You can build a db using JSON and import it into your Py file easily. I would read into the structure of JSON. Once you get a decent understand of building a correct, complex JSON file, you'll be able to use Py logic to parse through it.
{
"listStates": [
{
"stateName": "ALABAMA",
"filingStatus": [
{
"status": "SINGLE",
"incomeBrackets": [
{
"incomeMin": 0,
"incomeMax": 499,
"taxRate": 0.02
},
{
"incomeMin": 500,
"incomeMax": 2999,
"taxRate": 0.04
},
{
"incomeMin": 3000,
"incomeMax": 10000000000,
"taxRate": 0.05
}
]
},
{
"status": "MARRIED FILING JOINTLY",
"incomeBrackets": [
{
"incomeMin": 0,
"incomeMax": 999,
"taxRate": 0.02
},
{
"incomeMin": 1000,
"incomeMax" : 5999,
"taxRate": 0.04
},
{
"incomeMin": 6000,
"incomeMax": 10000000000,
"taxRate": 0.05
}
]
}
]
},
{
"stateName": "ALASKA",
"filingStatus": [
{
"status": "SINGLE",
"incomeBrackets": [
{
"income": 0,
"taxRate": 0.0
}
]
},
{
"status": "MARRIED FILING JOINTLY",
"incomeBrackets": [
{
"income": 0,
"taxRate": 0.0
},
{
"income": 0,
"taxRate": 0.0
}
]
}
]
},
{
"stateName": "ARIZONA",
"filingStatus": [
{
"status": "SINGLE",
"incomeBrackets": [
{
"income": 0,
"taxRate": 0.0259
},
{
"income": 27808,
"taxRate": 0.0334
},
{
"income": 55615,
"taxRate": 0.0417
},
{
"income": 166843,
"taxRate": 0.0450
}
]
},
}
Here is an example of iterating through the code above
i = 0
for states in data['listStates'][i]['stateName']:
if residence == data['listStates'][i]['stateName']:
print("1st for loop works")
i = i
print(data['listStates'][i]['stateName'])
else:
i += 1
As I said, this all depends on the scope of your project. But from what I understand is that Python reads the JSON data as if it were a dictionary. This is case specific code that I used here just so you'd get the idea.