5 Python Tricks That Distinguish Senior Developers From Juniors

Illustrated through differences in approaches to Advent of Code puzzles

Every year since 2015 on the first of December Advent of Code starts. As described on their website, Advent of Code (henceforth AoC) is

an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as interview prep, company training, university coursework, practice problems, a speed contest, or to challenge each other.

In this article, we’ll take a look at five approaches to tackle common coding problems in a senior way instead of a junior one. Each coding problem is derived from an AoC puzzle, with many problems recurring multiple times throughout AoC and other coding challenges and assessments you might encounter e.g. in job interviews.

To illustrate the concepts I won’t go into the solution of the full AoC puzzles, but rather only focus on a small part of a specific puzzle in which senior developers are easily distinguishable from juniors.

  1. Read in a file effectively with comprehensions and splits
    On Day1 of AoC it is required to read in several blocks of numbers. Each block is separated by an empty line (thus actually ‘\n’).

Input and desired output

Junior developer approach: a loop with if-else statements

Senior developer approach: make use of list comprehensions and

Using list comprehensions we can fit the nine previous lines into one, without losing significant understandability or readability, and while gaining in performance (list comprehensions are faster than regular loops). For those that haven’t seen map before, map maps a function (the first argument) to an iterable in the second argument. In this specific situation, it applies int() to every value in the list, making every item an integer. For more info about map click here.

  1. Use Enum instead of if-elif-else
    On Day2 the challenge revolves around a game of rock-paper-scissors. A different chosen shape (rock, paper, or scissors) results in a different amount of points: 1 (X), 2 (Y), and 3 (Z) respectively. Here below are two approaches to tackle this problem.

Input and desired output

Junior developer approach: if-elif-else

Of course, in this example, the naive approach isn’t that terrible but using Enum results in shorter and more readable code. Especially when more options are possible the naive if-elif-else approach will get worse and worse, while with Enum it stays relatively easy to keep an overview. For more on Enum click here.

  1. Use lookup tables instead of dictionaries
    In Day3 letters have different values. Lowercase a-z has values 1 through 26, and uppercase a-z has values 27 through 52. Because of the many different possible values, using Enum like here above would result in many lines of code. A more practical approach here is to use a lookup table:

Junior developer approach: creating a global dictionary

Senior developer approach: using a string as a lookup table

Using the .index() method of a string we get the index, hence letters.index(‘c’)+1 will result in the expected value of 3. There is no need to store the values in a dictionary because the index is the value. To prevent the +1 you could simply add a whitespace character at the beginning of the string so that the index of a starts on 1. However, this depends on whether you’d like to return a value of 0 for a whitespace or an error.

As you might have thought by now, yes, we could also solve the rock, paper scissors task using a lookup table:

El gato con botas: El último deseo Online Película Completa

El Gato con Botas 2: El Ultimo Deseo | PELíCULA COMPLETA Espanol Latino Full HD

El Gato con Botas 2: El último deseo 🎬 Full (HD) Película completa

el gato con botas 2 el último deseo (PELICULAS)

Operación Fortune: El gran engaño (Ver prueba gratuita)

Operación Fortune: El gran engaño Pelicula Completa en español

m3gan | Película Completa en Español

m3gan (2022) pelicula completa #2 Español


m3gan | Pelicula Completa en Español pelis

  1. Advanced slicing
    On Day5 it is required to read letters from lines (see input below). Each letter is on a fourth index, starting from index 1. Now, virtually every Python programmer will be familiar with string and list slicing using e.g. list_[10:20] . But what many people don’t know is that you can define step size using e.g. list_[10:20:2] to define a step size of 2. On Day5 (and in many other coding situations) this could save you a lot of unnecessarily complicated code:

Junior developer approach: double for loop with range and indices

Senior developer approach: using advanced slicing methods

  1. Use a class attribute to store class instances
    On Day11 a situation is described in which monkies pass objects to each other. In order to simplify we’ll pretend that they’re simply passing bananas to each other. Each monkey can be represented as an instance of a Python class with their id and their amount of bananas as instance attributes. However, there are many monkeys and they need to be able to interact with each other. A trick to store all the monkeys and for them to be able to interact with each other is to define a dictionary with all Monkey instances as a class attribute of the Monkey class. Using Monkey.monkeys[id] you can access all existing monkies without the need of a Monkies class or an external dictionary:

class Monkey:







m3gan korean full version

Operación Fortune: El gran engaño Completa en español



  1. Self-documenting expressions (BONUS)
    This trick is applicable virtually every time you write a Python program. Instead of defining in an f-string what you are printing (e.g.
    print(f”x = {x}”) you can use print(f”{x = }”) to print the value with a specification of what you are printing.

To conclude
We’ve looked at 5 Python tricks that distinguish senior developers from junior developers. Of course, only applying these tricks won’t promote someone suddenly to senior developer. However, through analyzing the difference in style and pattern between the two you can learn the difference in how a senior developer approaches coding problems versus a junior, and you can start to internalize these approaches so that you’ll eventually become a senior developer yourself!