title: How to create function that returns 'change in highest denominations'
body: <p>I am trying to make a programme that will return the correct change, in the highest denominations possible </p>
  
  <p>i.e $73 will return 1 x $50, 1 x $20, 1 x $2 and 1 $1 </p>
  
  <p>(I am using whole values of $100, $50, $20, $10, $5, $2, $1)</p>
  
  <p>I have a long code that works...it is</p>
  
  <pre><code>hundred = x // 100
  hundred_remainder = x % 100
  
  fifty = hundred_remainder // 50
  fifty_remainder = hundred_remainder % 50
  
  twenty = fifty_remainder // 20 
  </code></pre>
  
  <p>etc....then</p>
  
  <pre><code>if hundred &gt; 0:
      print (str(hundred) + " x $100")
  if fifty&gt; 0:
      print (str(fifty) + " x $50")
  </code></pre>
  
  <p>etc....which works fine, but I know there must be a way of writing a function that has a loop to work it out with less typing. Something like X = $345, then it gets 3 x $100, subtracts that from the total and updates X with the remainder, then repeats the process going through each denomination, until complete. I'm just a bit unsure how to figure it out, any guidance will be greatly appreciated!</p>