We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Category: List

Python : Different ways to Iterate over a List in Reverse Order

In this article we will discuss different ways to Iterate over a python list in reverse order. Suppose we have a python list of strings i.e. Advertisements # List of string wordList = [‘hi’, ‘hello’, ‘this’, ‘that’, ‘is’, ‘of’] Now we want to iterate over this list in reverse order( from end to start ) …

Python : Different ways to Iterate over a List in Reverse OrderRead More

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 : Sort a List of numbers in Descending or Ascending Order | list.sort() vs sorted()

In this article we will discuss how to sort a list of numbers in ascending and descending order using two different techniques. list.sort() vs sorted() list’s sort() function In Python, list provides a member function sort() that can sorts the calling list in place. Advertisements sorted() Function It’s a built in function that accepts an …

Python : Sort a List of numbers in Descending or Ascending Order | list.sort() vs sorted()Read More

Python : Check if all elements in a List are same or matches a condition

In this article we will dicuss different ways to check if all element in a given List are same or matches a condition. Suppose we have a list of string i.e. Advertisements # List of string listOfStrings = [‘Hello’] * 10 Now let’s use python all() function to check if all elements in the given …

Python : Check if all elements in a List are same or matches a conditionRead More

Python : Check if a list contains all the elements of another list

In this article we will discuss if a list contains all or any elements of another list. Suppose we have have two list i.e. Advertisements # List of string list1 = [‘Hi’ , ‘hello’, ‘at’, ‘this’, ‘there’, ‘from’] # List of string list2 = [‘there’ , ‘hello’, ‘Hi’] Check if list1 contains all elements of …

Python : Check if a list contains all the elements of another listRead More

Python : How to add an element in list ? | append() vs extend()

In this article we will discuss how to add element in an existing list using different techniques. Adding item in list using list.append() list.append(item) It adds the item at the end of list. Advertisements For example, we have a list of string i.e. # List of string wordList = [‘hi’, ‘hello’, ‘this’, ‘that’, ‘is’, ‘of’] …

Python : How to add an element in list ? | append() vs extend()Read 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

Python : How to Sort a list of strings ? | list.sort() Tutorial & Examples

In this article we will discuss how to sort a list of string by, By Alphabetical Order By Reverse Alphabetical Order By String Length By Numeric Order list.sort() list provides a member function sort(). It Sorts the elements of list in low to high order i.e. if list is of numbers then by default they will …

Python : How to Sort a list of strings ? | list.sort() Tutorial & ExamplesRead More

Python : How to create a list and initialize with same values

In this article we will discuss how to create a list and initialise with same values. Creating a list of same values by [] and multiply Suppose we want to create a list of strings, which contains 20 same strings i.e. ‘Hi’ Advertisements [‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, …

Python : How to create a list and initialize with same valuesRead More

Cart

Your Cart is Empty

Back To Shop