title: Return variable from function(A) not working in function(B)
body: <p>Im new to programming and I am trying to write two functions that generate between them a number that represents the number of travellers produced by a given population with a given weather.  The two functions wotk on their own but when I try to get the first function (weather_gen) to feed its output into the second function (traveller_gen) I get the following error:
  UnboundLocalError: local variable 'y' referenced before assignment.
  However, I know that the return value x from the first function is in the second function because the print(x) command works.  Its only when I ask the second function to return y that the problems arise.</p>
  <pre><code>import random
  
  season = &quot;summer&quot;
  p=100
  
  def weather_gen(season):
          
      weathers = (&quot;snow&quot;, &quot;rain&quot;, &quot;drizzle&quot;, &quot;sun&quot;, &quot;gorgeous&quot;)
          
      if  season == &quot;spring&quot;:
          x = (random.choices(weathers, weights=(10,30,30,20,10), k=1))
      if  season == &quot;summer&quot;:
          x = (random.choices(weathers, weights=(0,10,10,50,30), k=1))
      if  season == &quot;autumn&quot;:
          x = (random.choices(weathers, weights=(5,20,25,35,10), k=1))
      if  season == &quot;winter&quot;:
          x = (random.choices(weathers, weights=(20,25,25,15,5), k=1))
      return x
  
  x = weather_gen(season)     
  
  def traveller_gen(x):
      print(x)    
      if x == &quot;snow&quot;:
          t = random.randint(0, 10)
          y = (t/100)*p
      if x == &quot;rain&quot;:
          t = random.randint(40, 55)
          y = (t/100)*p 
      if x == &quot;drizzle&quot;:
          t = random.randint(50, 75)
          y = (t/100)*p 
      if x == &quot;sun&quot;:
          t = random.randint(85, 100)
          y = (t/100)*p 
      if x == &quot;gorgeous&quot;:
          t = random.randint(100, 125)
          y = (t/100)*p
      return y
      
  traveller_gen(x)
  </code></pre>
  <p>Have I missed something completely obvious?
  Best wishes,
  Saveric</p>