title: Python Random Number File Writer
body: <p>This is what I have so far. It worked until I added the functions. I need to have two functions in the code and I don't know how to make this work correctly and have tried several different ways. The code needs to write X amount of random numbers to a text file.</p>
  
  <pre><code>import random
  
  random_numbers = open('ran_numbers.txt', 'w')
  
  def main():
  
      getRandom()
      writeFunction()
  
  def getRandom():
      qty_numbers = int(input('How many random numbers should be written to the file? '))
  
      for count in range (qty_numbers):
          number = random.randint(1,500)
  
  def writeFunction():
      random_numbers.write(str(number)+ '\n')
      random_numbers.close()
      print('Your list of random numbers have been written to the file named')
      print('ran_numbers.txt')
  
  main()
  </code></pre>