Tag: item
Python : How to Check if an item exists in list ? | Search by Value or Condition
In this article we will discuss different ways to check if a given element exists in list or not. Table of Contents Introduction Check if element exists in list using python “in” Operator Check if element exist in list using list.count() function Check if element exist in list based on custom logic Introduction Suppose we …
Python : How to Check if an item exists in list ? | Search by Value or ConditionRead More
Python: How to sort a list of tuples by 2nd Item using Lambda Function or Comparator
In this article we will discuss how to sort a list of tuple using 2nd or i th item of tuple. Suppose we have a list of tuple i.e. words and thier frequency count, Advertisements # List of tuples i.e. word and its frequency count wordFreq = [ (‘the’ , 34) , (‘at’ , 23), …
Python: How to sort a list of tuples by 2nd Item using Lambda Function or ComparatorRead More
Javascript: Insert an item to array at specific index
While working with javascript arrays, often there is a requirement to insert an item at a specific index in javascript. This article will discuss adding an element to an array at a particular index. Table of Contents:- Insert element in array at specific position using splice() Insert element in array at specific position using reduce() …
Javascript: Insert an item to array at specific indexRead More
Count occurrences of an item in List in Python
In this article, we will discuss different ways to count the occurrences of an element in a list in Python. Table Of Contents Introduction Get Occurrence count of a value in list using count() Get Occurrence count of a value in list using for-loop Get Occurrence count of a value in list using operator.countof() Get …
Find the index of an item in List in Python
In this article, we will discuss different ways to find the index of a given item in a list in Python. Table of Contents Find index of an item in list using index() function Find all indices of an item in list Summary Find index of an item in list using index() function In Python, …
Count occurrence of an item in List in Python
In this article, we will discuss different ways to count the occurrence of an item in a List in Python. Table Of Contents Count occurrence of an item in List using count() method Count occurrence of an item in List using for loop Count occurrence of an item in List using operator Count occurrence of …
Create List of single item repeated N times in Python
In this article, we will learn different ways to create a list of single item repeated N times in Python. Table Of Contents Method 1: Using Astrik Method 2: Using List comprehension Method 3: Using itertools Summary Method 1: Using Astrik We can create a list object with one element only, and then multiply that …
Create List of single item repeated N times in PythonRead More
Check if Any item of List is Not in Another List in Python
This tutorial will discuss about a unique way to check if any element of a list is not in another list in Python. Suppose we have two lists, list1 = [11, 22, 33, 44, 55] list2 = [67, 78, 49, 34, 19, 27] We want to check if any element from first list list1 is …
Check if Any item of List is Not in Another List in PythonRead More