While writing code, we should avoid duplication because:
- It is redundant
- If we make a change to one piece of code, we need to remember to make the same change to another piece of code. Otherwise, we will introduce bugs into our code.
In the code above, we use the filter X['date'] > date(2021, 2, 8)
twice. To avoid duplication, we can assign the repeated code to a variable or a function.