5 Python one liners that speed up code

What is a one liner?

You can think of one liner code as a block or segment of code compressed in one line to perform the similar function. This one liner saves you a lot of time, memory and you can also trick your friends or fellow programmers. It also keeps your program simple, clean, short and simple with less lines of code.

            One need to be careful by using them, while Python is known for its ease of understanding and readability. You should keep in mind not to violate this feature.

Now let’s start!

  • For loop in one line

If for loop is used in a list then use the below one.

  • Swap variables
  • Fibonacci
  • Reverse a string
  • Print a pattern

These are some of the one liners in Python. Many more are there it’s always exciting while learning a new language to try these sorts of things. If you know any other one liners in Python leave your comment below.