• 01 April

    Remove from list Python

    In this post, we will see how to remove an element from list in python. You can remove elements from list in 3 ways. Using list object’s remove method Here you need to specify element which you want to remove. If there are multiple occurrences of element, then first occurrence will be removed. Please note […]

  • 23 December

    Python sort list of tuples

    In this tutorial, we will see about how to sort list of tuples on the basis of various criterion. Let’s understand with the help of example Let’s say you have list of tuples as below: [crayon-61705178a57eb136243494/] Now you want to sort list of tuples based on age and age is 1st index in tuple. You […]

  • 08 December

    Python Convert list to set

    In this tutorial, we will see how to convert list to set. You can use python set() function to convert list to set.It is simplest way to convert list to set. As Set does not allow duplicates, when you convert list to set, all duplicates will be removed in the set. Let’s understand with the […]

  • 08 December

    How to create an empty list in python

    In this post, we will see how to create an empty list in python. There are two ways to create an empty list in Python. Using [ ] Using list() function. Let’s see this with the help of example. list1=[] list1.append(1) list1.append(2) list2=list() list2.append(1) list2.append(2) print("List 1:",list1) print("List 2:",list2) [/datacamp_sample_code] [/datacamp_exercise] Output: List 1: [1, […]

  • 08 December

    convert set to list Python

    In this tutorial, we will see how to convert set to list in python. You can use python list() function to convert set to list.It is simplest way to convert set to list. Let’s understand with the help of example. [crayon-61705178a6ffb736667723/] Output: set of Fruits: {‘Apple’, ‘Banana’, ‘Orange’} listOfFruits: [‘Apple’, ‘Banana’, ‘Orange’] set of scales: […]

  • 08 December

    Python tuple index()

    In this post, we will see about Python tuple’s index method.Python tuple’s index method is used to find index of element in the tuple Python tuple count syntax [crayon-61705178a7c60378160990/] tuple1 is object of the tuple and element is the object which you want to get index. Python tuple count example Python tuple index method is […]

  • 08 December

    Python tuple count()

    In this post, we will see about Python tuple’s count method.Python tuple’s count method is used to count the occurrences of element in the tuple. Python tuple count syntax [crayon-61705178a88cc342194861/] tuple1 is object of the tuple and element is the object which you want to get count. Python tuple count example Let’s understand count method […]

  • 07 December

    python – check if list is empty

    In this post, we will see how to check if list is empty in python. It is very easy to check if list is empty in python. You can use "not" to check if list is empty in Python. Let’s understand with the help of simple example. [crayon-61705178a9fdc393713724/] Output: list1 is not empty list2 is […]

  • 07 December

    Python List append()

    In this tutorial, we will see about Python List‘s append method.Python List append is used to add single element to end of the list. Let’s understand about basic of python list first. Python List is nothing but the collection of elements. You can add any data type to the list. You can create simple list […]