Question: I have one bad-formatted python dictionary:

```
poke = "{
    bulbasaur: {
        num: 1,
        name: "Bulbasaur",
        types: ["Grass", "Poison"],
        genderRatio: {M: 0.875, F: 0.125},
        baseStats: {hp: 45, atk: 49, deff: 49, spa: 65, spd: 65, spe: 45},
        abilities: {0: "Overgrow", H: "Chlorophyll"},
        heightm: 0.7,
        weightkg: 6.9,
        color: "Green",
        evos: ["ivysaur"],
        eggGroups: ["Monster", "Grass"],
    },

```

(as you can imagine there's a list of all pokemon)

so I want to add `"` just before `:`, and in the beggining of that word, so I can have a Python dictionary.

How can I do this?

Thank you!

Answer: 
This string looks like a valid `jsonnet` or `YAML`

Just use the right module to parse:

```
import json
import _jsonnet

json_str = _jsonnet.evaluate_snippet(
    "poke", poke)

json_obj = json.loads(json_str)

```

Example taken from [here](https://jsonnet.org/ref/bindings.html)
Is the string formatted the way you posted with newline characters separating lines? If this is the case here's the solution to your problem, I will write in pseudo since it is pretty straightforward to translate it in Python, they are almost the same.

```
- Loop over each poke
- Split over \n to get the pairs k,v
- For each k,v split on the ':' character, map each element e to " + e + " and finally join them on ':'.

```