Remove Null Value from a List in Python

Utkarsha Nathani
Updated on 24-Apr-2023 09:17:20

12K+ Views

This article discusses how to remove null values from a Python list. Before proceeding, it is necessary to understand what a null value is? What a List is? Why it is necessary to remove null value from list. Let’s move ahead with the topic and understand them in detail. Let’s start with the Null value. Null Value is defined as a parameter that does not have a value. It indicates the absence of a value. Python has a special value for "Null" that shows a variable doesn't point to anything. But in Python there is no null, there ... Read More

Check If Two Sets Are Equal in Python

Utkarsha Nathani
Updated on 24-Apr-2023 09:00:26

10K+ Views

Python is an interpreted, object–oriented, high level, programming language with dynamic semantics. Developed by Gudio Van Rossum in 1991. It supports multiple programming paradigms, including structured, object-oriented and functional programming. What Is A Set? Set is an unordered collection data type that iterable, mutable and has no duplicate element. Set is represented by {}. Set is highly optimized method for checking whether a specific element is present in the set. Sets are created by placing all the items or elements inside curly brackets {}, separated by comma, or by using built in “set ()” function. It can have various ... Read More

Swift Program to Print a Set

Ankita Saini
Updated on 24-Apr-2023 08:59:33

540 Views

In Swift, a set is used to define a collection of unique elements, means a set doesn’t contains duplicate elements. In a set, the elements are not arranged in a particular order. To print a set we can use for-in loop, forEach() function, as well as the name of the set. Lets discuss all the methods one by one in detail along with examples. Method 1: Name of the Set To print a set we simply call the name of the set in the print() function. It will display set elements in the square bracket([]). Or we can say that ... Read More

Get Substring Between Two Similar Characters in JavaScript

Yaswanth Varma
Updated on 21-Apr-2023 17:32:09

4K+ Views

Before we are going to learn about how to get substring between two similar characters in JavaScript. Let’s have a quick view on the characters in JavaScript. In a string, the charAt() method returns the character that is located at the given index (position). First character's index is 0, second character's index is 1. Getting substring in JavaScript The substring() method takes a string and extracts all characters between two indices (positions), then it returns the substring. Characters are taken out of a string using the substring() technique. The initial string is left alone when using the substring() technique. Syntax ... Read More

Sorting an Array Containing Undefined in JavaScript

Yaswanth Varma
Updated on 21-Apr-2023 17:30:37

3K+ Views

In JavaScript Arrays are used to hold several values in a single variable. When opposed to a variable, which can hold only one value, this Each element of an array has a number associated with it called a numeric index that enables access to it. Arrays in JavaScript begin at index zero and can be modified using a number of different techniques. Let's take a look at the general case of sorting an array that contains undefined in JavaScript. The array is given below − var namearr = ["Zebra", "Yatch", undefined, "Egg", undefined]; For sorting the array that was ... Read More

Display JavaScript DateTime in 12-Hour AM/PM Format

Yaswanth Varma
Updated on 21-Apr-2023 17:28:47

3K+ Views

The most practical way to display datetime for efficient time analysis is in a 12 hour am/pm format. Additionally, this method clarifies the distinction between morning and evening. As an illustration, "am/pm" both specify a certain time period and make it simple to understand the time, which is not the case with the 24-hour format. This article will explain the ways of displaying JavaScript datetime in 12hour am/pm format. Displaying JavaScript datetime in 12hour am/pm format Let’s dive one by one to understand more about displaying JavaScript datetime in 12hoyur am/pm format. We can extract the hours and minutes from ... Read More

Substitute Random Items in a JavaScript Array

Yaswanth Varma
Updated on 21-Apr-2023 17:26:42

388 Views

To substitute random items with items from an array with different ones in JavaScript. Let’s look at the instance; the array is − Var array=[m, n, o, p] Let's choose two random items to be replaced with a, while the others remain in their original positions. If m and n are the randomly selected items, and one is removed on one instance, the array would be − Changed array=[a, a, o, p] Let’s dive into the article to learn more about substituting random items in a JavaScript array. To substitute random items, use random() along with map(). Using ... Read More

Detect and Replace Array Elements in a String using RegExp in JavaScript

Yaswanth Varma
Updated on 21-Apr-2023 17:24:34

1K+ Views

An array is an ordered list of values in JavaScript. The term "element designated by an index" refers to each value: The following traits describe a JavaScript array: An array can initially store values of many sorts. You could, for instance, store elements of the number, string, Boolean, and null types in an array. Let’s jump into the article to detect and replace all the array elements in a string using regexp in JavaScript. Using regexp in JavaScript A regular expression is a character pattern. Pattern-matching "search-and-replace" operations are performed on text using the pattern. A RegExp Object is a ... Read More

Make Strings in Array Become Keys in Object in a New Array in JavaScript

Yaswanth Varma
Updated on 21-Apr-2023 17:23:05

2K+ Views

The task we are going to perform in this article is make strings in array become keys in object in a new array in JavaScript. Let’s consider a simple array − let array= ['bike', 'car'] Now, we are going to use map() to convert the above array to a new array (keys in an object). The array will then look like this − let newArray= [{shorts: []}, {tees: []}, ] Let’s dive into the article to learn more about on making a strings in array become keys in object in a new array in JavaScript. Using map() The ... Read More

Count Number of Occurrences of Repeated Names in an Array Using JavaScript

Yaswanth Varma
Updated on 21-Apr-2023 17:05:26

1K+ Views

An array in JavaScript is a group of identically typed elements that are stored in adjacent memory locations and may each be separately referred to using an index to a special identifier. Let’s consider an array consisting of occurrences of repeated names. The array looks like this − var details = [ { studentName: "John", studentAge: 23 }, { studentName: "David", studentAge: 24 }, ... Read More

Advertisements