title: Assigning function print output to string variable
body: <p>I have the below function that loops through two lists and prints out a selection of vegetables and then fruits.</p>
  
  <pre><code>def Selection():
      print("VEGETABLES FOR THE WEEK:\n")
      for veg in veg_selection:
          print(veg.upper())
      print("\n")
      print("FRUITS FOR THE WEEK:\n")
      for fruit in fruit_selection:
          print(fruit.upper())
  </code></pre>
  
  <p>So the result could look like:</p>
  
  <pre><code>VEGETABLES FOR THE WEEK:
  
  BROCOLLI
  PEAS
  CARROTS
  SWEET CORN
  WHITE ONIONS
  
  
  FRUITS FOR THE WEEK:
  
  GRAPEFRUIT
  CHERRIES
  ORANGE
  COCONUT
  RASPBERRIES
  </code></pre>
  
  <p>I'm struggling to get my head around assigning the printed results of the function to a single variable that contains the formatted string. Would I need to save the results as a text file and then read it in again? Can I just use text concatenation? I'm unsure how to deal with the for loops in the function? Any help really appreciated.</p>