Writing reusable code
<p>I find myself constantly having to change and adapt old code back and forth repeatedly for different purposes, but occasionally to implement the same purpose it had two versions ago.</p>

<p>One example of this is a function which deals with prime numbers.  Sometimes what I need from it is a list of n primes.  Sometimes what I need is the nth prime.  Maybe I'll come across a third need from the function down the road.</p>

<p>Any way I do it though I have to do the same processes but just return different values.  I thought there must be a better way to do this than just constantly changing the same code.  The possible alternatives I have come up with are:</p>

<ol>
<li><p>Return a tuple or a list, but this seems kind of messy since there will be all kinds of data types within including lists of thousands of items.</p></li>
<li><p>Use input statements to direct the code, though I would rather just have it do everything for me when I click run.</p></li>
<li><p>Figure out how to utilize class features to return class properties and access them where I need them.  This seems to be the cleanest solution to me, but I am not sure since I am still new to this.</p></li>
<li><p>Just make five versions of every reusable function.</p></li>
</ol>

<p>I don't want to be a bad programmer, so which choice is the correct choice?  Or maybe there is something I could do which I have not thought of.</p>
