earn the White PyBites Ninja earn the Yellow PyBites Ninja earn the Orange PyBites Ninja right arrow earn more PyBites Ninja belts and certificates
The best way to learn to code in Python is to actually use the language.

Our platform offers effective Test Driven Learning which will be key to your progress.

Join thousands of Pythonistas and start coding!

Join us on our PyBites Platform
Click here to code!

Code Challenge 30 - The Art of Refactoring: Improve Your Code

Posted by PyBites on Tue 01 August 2017 in Challenges • 2 min read

A smooth sea never made a skilled sailor. - Franklin D. Roosevelt

Hi Pythonistas, a new week, a new 'bite' of Python coding. Wow challenge 30 already! This week we let you hone your refactoring skills. Learn, code, PR submit (don't be shy) and above all have fun!

The challenge

The challenge is pretty simple:

  • Go through you code and identify something you think can be improved.

  • Write some tests to verify it does the right thing. This could be with Pytest, unittest or just adding a simple assert, just have a safeguard in place before starting to touch the code. Version control is your other friend here.

  • Iterate over various small improvements, running the tests after each step to verify nothing breaks.

  • When done submit a PR for our weekly review - this week we will be extra picky on PEP8 compliance! ;)

Update: somebody asked for scripts to refactor. Excellent point. As refactoring is such an important skill we will do a part II sometime soon where we will give you a couple of PyBites scripts to refactor!

Need help?

Here are some resources you could use:


Worth checking out!



Getting ready

See our INSTALL doc how to fork our challenges repo to get cracking.

This doc also provides you with instructions how you can submit your code to our community branch via a Pull Request (PR). We will feature your PRs in our end-of-the-week challenge review (previous editions).


If you have ideas for a future challenge or find any issues, open a GH Issue or reach out directly.

Last but not least: there is no best solution, only learning more and better Python. Good luck!

Keep Calm and Code in Python!

-- Bob and Julian

See an error in this post? Please submit a pull request on Github.