top of page
  • Writer: VC Healy
    VC Healy
  • Jul 31, 2020
  • 1 min read

Remove Duplicates, Capitalise Names, Change the Order, Find the smallest first name.


This was a great challenge, I got the tasks to work individually but then came the challenge of the secondary functions feeding of the output of the primary function.

This presented me with a couple of issues in the secondary functions, the received code from the primary had to be manipulated a little differently.

Another I encountered was that the output from the secondary function was giving double, treble the amount of output. I worked through this methodically and found the issue to be the use of a global variable by more than one function. Thus the list I thought to be empty held data. The solution, bring all the variables local to the functions.



 
 
  • Writer: VC Healy
    VC Healy
  • Jul 31, 2020
  • 2 min read

I have a system that I use every time I am looking at a PyBite with vs Code. I create three files

temp.py, Now I could have called this a txt file but I wrapped the text, triple ''', as it giive a better colour to read.

pytest.py, to have a copy of the tests that will be performed on my code.

app.py The main code that I am working on.


The temp file, this gets a full copy of the text for the question. I then edit the text to show steps that would be needed to complete each task asked. Number them, bullet point them, whatever works for you but this will give you a checklist to work through.


pytest file, I have a look over this file and see how the tests match up with the points in the temp file.


Now I create a blank app file. I don't copy over the code for the webpage. No, I prefer to write it from scratch, no need for the function header. Just write the code to cover the action required and end thee code with a print statement to check the end result

I work through all of the tasks in the temp file building on the code from the previous task. I place print statements at pinch points in the code. Remarked out unless needed to check something.

Once I get to the end of the tasks copy in the code from the web page at the top of the page, remarking out all the previous code I had written. Then I can get on with copying in my previous code for each task in turn and edit the code to suit the requirements if they differ from my initial write.


Now confident, I start to check through the assertions of the pytest to make sure it is all working as expected.


Final step. post the code to the website and submit, if there is an error or assertion issue. I will go back and work through each task once more.

 
 
  • Writer: VC Healy
    VC Healy
  • Jul 30, 2020
  • 1 min read

A great we bite this time.

If no value then a default value should be returned, with the exception of an empty list. The empty list should return the value 0. A little more tricky as an empty list has a value of None.

It is all in how you grab the argument.



 
 

© 2020 by Vincent Healy. Proudly created with Wix.com

bottom of page