Question: I have the next regular expression: `/i18n(-?).*="(.*)"/g` for javascript.

I use <https://www.regextester.com> to check.

```
<button i18n="@@user.button" data-test="download-confirmation_ok">
<a i18n-href="@@link.url" href="https://www.aaaa.es" target="_blank">
<div i18n="@@link.text">www.aaaa.es</div>

```

I don't like `data-test="download-confirmation_ok"` and `href="https://www.aaaa.es" target="_blank"`:
<https://imgur.com/sQZQXzZ>

I only want i18n or i18n-\* text between "TEXT".

How can I discard rest of the tetx?

Thank.

Answer: 
You might be looking for `defaultdict` from collections in the standard library. Creating a `defaultdict` with `dict` as default factory will enable you to write to `frequencyLomb[J][K]` without first creating dict at `frequencyLomb[J]`.

```
from collections import defaultdict

frequencyLomb = defaultdict(dict)

for J in range(1, 81, 4):
  n_items = take(dataDays.values(), J - 1, J + 3)
  for K in range(1,5):
    temp_time=n_items[K-1][0]
    temp_flux=n_items[K-1][1]
    mean_temp_flux=np.mean(temp_flux)

    temp_flux_final=temp_flux-mean_temp_flux
    frequencyLomb[J][K] = freq_grid(temp_time)

```
Try something like this:

```
if j not in frequencyLomb: #Then try frequencyLomb[J] = {} and then frequncyLomb[J][K] = Your Value

else: #Then directly add your value to the inner dictionary.

```