title: Swap values and keys in a dictionary
body: <p>I want to swap the years with the continent so that the continent is the primary key and the year the secondary one</p>
  <pre><code>    def get_most_infected_continents() -&gt; List[Dict[str, any]]:
      &quot;&quot;&quot;We calculate the most infected continents.&quot;&quot;&quot;
      lst : List = list()
      string = &quot;&quot;
      for i in range(1990, 2021):
          dict2 = {}
          dict3 = {}
          dict1 = {}
          for dct in dataset:
              if dct[str(i)] == -1 or dct['continent'] == &quot;Global&quot;:
                  continue
              if dct[&quot;continent&quot;] not in dict2 :
                  dict2[dct[&quot;continent&quot;]] = dct[str(i)]
              else:
                  dict2[dct[&quot;continent&quot;]] += dct[str(i)]
          maxim = 0
          for key in dict2:
              if int(dict2[key]) &gt; maxim:
                  maxim = dict2[key]
                  string = key
          dict3[string] = maxim
          dict1[str(i)] = dict3
          lst.append(dict1)   
      return lst
  get_most_infected_continents()
  </code></pre>
  <p>This is how the output kinda looks</p>
  <pre><code>[{'1990': {'Africa': 5736700}},
  {'1991': {'Africa': 7026700}},
  {'1992': {'Africa': 8423800}},
  {'1990': {'Africa': 5736700}},
  {'1991': {'Africa': 7026700}},
  {'1992': {'Africa': 8423800}},....]
  </code></pre>
  <p>I would like to be</p>
  <pre><code>{'Africa': {'1990': 5736700}},...
  </code></pre>
  <p>The original dataset looks something like this but with all the countries:</p>
  <pre><code>country,continent,1990,1990_lower,1990_upper,1991,1991_lower,1991_upper,1992,1992_lower,1992_upper,1993,1993_lower,1993_upper,1994,1994_lower,1994_upper,1995,1995_lower,1995_upper,1996,1996_lower,1996_upper,1997,1997_lower,1997_upper,1998,1998_lower,1998_upper,1999,1999_lower,1999_upper,2000,2000_lower,2000_upper,2001,2001_lower,2001_upper,2002,2002_lower,2002_upper,2003,2003_lower,2003_upper,2004,2004_lower,2004_upper,2005,2005_lower,2005_upper,2006,2006_lower,2006_upper,2007,2007_lower,2007_upper,2008,2008_lower,2008_upper,2009,2009_lower,2009_upper,2010,2010_lower,2010_upper,2011,2011_lower,2011_upper,2012,2012_lower,2012_upper,2013,2013_lower,2013_upper,2014,2014_lower,2014_upper,2015,2015_lower,2015_upper,2016,2016_lower,2016_upper,2017,2017_lower,2017_upper,2018,2018_lower,2018_upper,2019,2019_lower,2019_upper,2020,2020_lower,2020_upper
  Afghanistan,Asia,&lt;500 ,&lt;200 , &lt;1000,&lt;500 ,&lt;200 , &lt;1000,&lt;500 ,&lt;200 , &lt;1000,&lt;1000 ,&lt;500 ,1100,&lt;1000 ,&lt;500 ,1300,&lt;1000 ,&lt;500 ,1600,&lt;1000 ,&lt;500 ,1900,1000,&lt;500 ,2100,1200,&lt;1000 ,2500,1300,&lt;1000 ,3000,1500,&lt;1000 ,3600,1800,&lt;1000 ,4100,2000,1100,4800,2300,1300,5700,2600,1400,7000,2900,1500,7200,3200,1700,7900,3500,1800,8300,3800,2000,8900,4200,2100,9600,4600,2300, 11 000,5100,2500, 12 000,5600,2700, 14 000,6300,3100, 16 000,6900,3300, 18 000,7600,3600, 21 000,8400,3900, 24 000,9200,4100, 28 000,10 000 ,4300, 33 000,11 000 ,4500, 38 000,12 000 ,4700, 43 000
  Albania,Europe,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;100,&lt;100 ,&lt;100 , &lt;200,&lt;100 ,&lt;100 , &lt;200,&lt;200 ,&lt;100 , &lt;200,&lt;200 ,&lt;200 , &lt;200,&lt;200 ,&lt;200 , &lt;500,&lt;500 ,&lt;200 , &lt;500,&lt;500 ,&lt;500 , &lt;500,&lt;500 ,&lt;500 , &lt;500,&lt;500 ,&lt;500 , &lt;500,&lt;500 ,&lt;500 , &lt;1000,&lt;1000 ,&lt;500 , &lt;1000,&lt;1000 ,&lt;1000 , &lt;1000,&lt;1000 ,&lt;1000 , &lt;1000,&lt;1000 ,&lt;1000 , &lt;1000,&lt;1000 ,&lt;1000 ,1000,1000,&lt;1000 ,1100,1100,&lt;1000 ,1200,1200,&lt;1000 ,1300,1300,1100,1400,1300,1100,1500,1400,1200,1600,1400,1200,1700
  .....
  </code></pre>