Better Programming

Advice for programmers.

Member-only story

7 Lesser-Known Python Tips to Write Elegant Code

Zeya LT
11 min readJan 27, 2022

--

Photo by Chris Ried on Unsplash

Recently, I participated in a Python programming Bootcamp, organised by Rodrigo Girão Serrão, author of the mathspp blog. This Bootcamp uses the Advent of Code platform, a cool programming event that happens annually from 1 to 25 December. Each day, the site publishes two new puzzles to solve.

Overall, it was a great learning experience. I learned tons of tips not only from the organiser but also fellow boot campers. There was a strong emphasis on maximising the use of Python’s built-in functions and modules, as well as writing clean and elegant code.

This post is as much my way of documenting these new tips I learned, as it is my effort to share them with you. They have helped to significantly improve my Python programming skills and I hope they help you too in the same way. Are you ready? Let’s dive right in!

Table of Contents

  1. The under-rated enumerate()
  2. The int() function is more useful than you think
  3. Let’s assert that assertstatement!
  4. Unpacking and packing — the power

--

--

Zeya LT
Zeya LT

Written by Zeya LT

Data Scientist @ Grab • Former Police Officer • Master’s in Data Science & Analytics • Mid-Career Switcher • Father of Two