title: How to obtain a value from inside a loop
body: <p>I will be implementing multiprocessing so that the loops are occurring at the same time, but how can I make it so at the end of each iteration, I can obtain the value of <code>westernEurope.cases</code> and <code>easternEurope.cases</code> so that I can add them together</p>
  <pre><code>westernEurope = Region(&quot;Western Europe&quot;, 1000, 0, 0, 8, 4, 4, 0)
  while westernEurope.deaths &lt; westernEurope.population:
      westernEurope.infection()
      if westernEurope.cases &gt; westernEurope.population:
          westernEurope.cases = westernEurope.population
      print(&quot;Infections:&quot;, westernEurope.cases)    
      westernEurope.death()
      if westernEurope.deaths &gt; westernEurope.population:
          westernEurope.deaths = westernEurope.population
      print(&quot;Deaths:&quot;, westernEurope.deaths)
      #where i want to return the value of westernEurope.cases
      time.sleep(0.1)
  
  easternEurope = Region(&quot;Eastern Europe&quot;, 1000, 0, 0, 8, 4, 4, 0)
  while easternEurope.deaths &lt; easternEurope.population:
      easternEurope.infection()
      if easternEurope.cases &gt; easternEurope.population:
          easternEurope.cases = easternEurope.population
      print(&quot;Infections:&quot;, easternEurope.cases)    
      easternEurope.death()
      if easternEurope.deaths &gt; easternEurope.population:
          easternEurope.deaths = easternEurope.population
      print(&quot;Deaths:&quot;, easternEurope.deaths)
      # where i want to return the value of easternEurope.cases
      time.sleep(0.1)
  
  print(easternEurope.cases + westernEurope.cases)
  </code></pre>