Python List reverse()

This tutorial shows you everything you need to know to help you master the essential reverse() method of the most fundamental container data type in the Python programming language. Definition and Usage: The list.reverse() reverses the order of the elements in the list. If you want to create a new list with reversed elements, use slicing with negative step size list[::-1]. Here’s a short example: >>> lst = [1, 2, 3, 4] >>> lst.reverse() >>> lst [4, 3, 2, 1] In the first line of the example, you create the…

Read More

JavaScript Reverse String – 4 Ways

In this tutorial I will talk about how you can reverse a string in JavaScript language. This is a very popular question i.e. asked in interviews. There are many ways in which we can reverse a string. Here I will discuss different ways in which we can achieve this. JavaScript Reverse String Using Buitin Function To reverse a string using built-in methods we have to chain some methods like join, split and reverse. For this first, we need to convert the string into an array by using split method then…

Read More

Reverse Lookups with JavaScript

I’ve always loved exploring regular expressions because they’re one of those skills that’s never taught in school — you need to pick them up on the fly, messing up and fixing them along the way. Regex’s are incredibly powerful, and one power they have are referred to as backreferences, which essentially allow you to use a match within the same regular expression. The easiest way to explain a backreference is with a simple goal: using a regex to simulate destructuring. Take the following code snippet: const body = document.blah.body; With…

Read More