Updating the function code

Adding the code created for this homework assignment.