• Image
    18 November

    Print Array in Python

    In this post, we will see how to print array in Python. As we know that, Python didn’t have an in-built array data type, so we try to use list data type as an array. We can also use the NumPy module for creating NumPy array and apply array operation on it. Now, we will […]

  • Image
    21 April

    Remove first element from list in Python

    In this post, we will see how to remove the first element from a list in python. Using list.pop() We can use list.pop() method to remove the first element from the list. [crayon-6988aafa26fc0272920784/] Output: List Of Fruits are: [‘Orange’, ‘Apple’, ‘Grapes’, ‘Mango’] List Of Fruits after removing first element: [‘Apple’, ‘Grapes’, ‘Mango’] Removed Fruit: Orange […]

  • Image
    26 March

    Find average of list in Python

    There are multiple ways to find the average of the list in Python. Using sum() and len() We can use sum() to find sum of list and then divide it with len() to find average of list in Python. Here is the quick example of the same. [crayon-6988aafa2710d449709314/] Output: Average of listOfIntegers: 3.0 Using reduce(), […]

  • Image
    22 December

    Python list of lists

    In this post, we will see how to create a list of lists in python. It is quite easy to create list of lists in Python. You just need to use list’s append method to create list of lists. Here is simple example to create list of lists in Python. [crayon-6988aafa271c4126252682/] Output: List of Lists: […]

  • Image
    21 December

    Combine two lists in Python

    In this tutorial, we will see how to combine twolist in python There are multiple ways to combine list in python. Using + operator You can use + operator to combine list in python. Let’s understand with the help of example. [crayon-6988aafa27363440793193/] Output: Combined List: [1, 2, 3, 4, 5, 6, 7, 8] As you […]

  • Image
    21 December

    Python count items in the list

    In this tutorial, we will see how to count items inlist in python Count total items in the list You can use len() function to count items in the list. Let’s understand with the help of example. [crayon-6988aafa27471440818140/] Output: List: [1, 2, 3, 4] Length of list1: 4 Count occurence of each element in the […]

  • Image
    19 December

    Python list to tuple

    In this tutorial, we will see how to convert list to tuple. Using tuple function You can use python tuple() function to convert list to tuole.It is simplest way to convert list to tuple. Let’s understand with the help of example. [crayon-6988aafa27545442385290/] Output: List of Fruits [‘Apple’, ‘Orange’, ‘Grapes’, ‘Banana’] Tuple of Fruits: (‘Apple’, ‘Orange’, […]

  • Image
    10 October

    Convert String to List python

    In this post, we will see how to convert String to list in Python. We can use String’s split function to convert String to list. String’s split function Python String split function signature [crayon-6988aafa27603148801314/] Parameters sep: A string parameter that will be used as a separator. maxsplit: Number of times split Let’s see some examples. […]

  • Image
    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-6988aafa276d8409990855/] Output: List Of Countries are: [‘India’, ‘China’, ‘Bhutan’, ‘Nepal’] List Of Countries after removing last element: [‘India’, ‘China’, ‘Bhutan’] Removed country: Nepal […]