• 08 October

    Remove last element from list python

    In this post, we will see how to remove the last element from a list in python. Using list.pop() You can use list.pop() method to remove the last element from the list. [crayon-62b8f6609575d857897909/] Output: List Of Countries are: [‘India’, ‘China’, ‘Bhutan’, ‘Nepal’] List Of Countries after removing last element: [‘India’, ‘China’, ‘Bhutan’] Removed country: Nepal […]

  • 01 April

    Python Convert List to String

    In this post, we will see how to convert a list to String in Python. You can simply use string’s join method to convert a list to String in Python. String’s join method string’s join method return string in which element of the sequence is joined by separator. [crayon-62b8f660962de703289962/] Let’s see some examples. Join all […]

  • 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-62b8f66096e86009838931/] 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. [crayon-62b8f660979b7522362478/] Output: List 1: [1, 2] List 2: [1, 2] Which is faster: [ ] or […]

  • 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-62b8f66097fb2756960053/] 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-62b8f660984f4433402231/] 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-62b8f660989e8725598173/] 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 […]