Sayantan's Blog On Python Programming

PYTHON LISTS

PYTHON LISTS

PYTHON LIST BUILT-IN FUNCTIONS

PYTHON LIST BUILT-IN FUNCTIONS INTRODUCTIONS Python provides some useful built-in functions which can be used while working with lists. len() FUNCTION len() function returns the no of elements present in a list including duplicates. PYTHON LIST BUILT-IN FUNCTIONS : Output count() FUNCTION count() function returns the number of occurrences of an element in a given …

PYTHON LIST BUILT-IN FUNCTIONS Read More »

REMOVING DUPLICATES USING PYTHON SET

REMOVING DUPLICATES USING PYTHON SET INTRODUCTION We can remove duplicate elements by using python set() operator. REMOVING DUPLICATES IN STRING LIST We can remove duplicates using set() operator in Python. REMOVING DUPLICATES USING PYTHON SET : Output In the above example we can see that the element “Python” was appeared thrice in the list. But …

REMOVING DUPLICATES USING PYTHON SET Read More »

LIST SORTING OPERATIONS

LIST SORTING OPERATIONS INTRODUCTIONS Python lists can be sorted either in forward or backward direction by using below methods: sort() FUNCTION sort() FUNCTION helps us to sort the list in ascending order. LIST SORTING OPERATIONS : Output LIST SORTING OPERATIONS : Output In the above example we have seen after calling sort() function the list …

LIST SORTING OPERATIONS Read More »

STEP SIZE IN PYTHON LIST SLICING

STEP SIZE IN PYTHON LIST SLICING INTRODUCTION Step size allows us to put filter on sliced data. POSITIVE STEP SIZE IN LIST SLICING Syntax : [start_index : end_index : setp_size] STEP SIZE IN PYTHON LIST SLICING : Output STEP SIZE IN PYTHON LIST SLICING : Output In the above example, we have used the complete …

STEP SIZE IN PYTHON LIST SLICING Read More »

PYTHON LIST SLICING OPERATION

PYTHON LIST SLICING OPERATION INTRODUCTION Before understanding slicing operation lets look at some list accessing methods by using index values. PYTHON LIST SLICING OPERATION : Output In the above example, we have used positive index as well as negative index. Negative index will be counted from the end of the list. In the above case, …

PYTHON LIST SLICING OPERATION Read More »