Python Tips and Tricks (July-2021)

Make your Python code efficient!

Pratik Gandhi
3 min readJul 27, 2021

The goal of writing this post is to put together all the tips/tricks I shared on my Twitter, in a single place during the month of July-2021. I try to learn new things in Python every day and share them via Twitter. Below are the snippets and all of them self-explanatory:

1. Sum of every nth element:

2. Max/Min times repeated element in a list:

3. Sort the dictionary based on the value:

4. Apply multiple conditions in a list instead of if/else:

5. Combine two lists in a dictionary:

--

--