Sort list in Python

Posted on Updated on

Python has different methods to sort elements of a list. These methods arrange elements in their natural order either in ascending or descending order. For example, if the elements are all integers, then smaller numbers go earlier in the list. If the elements are all strings, they are arranged in alphabetic order. Below are examples to sort list using list.sort(), sorted() method in ascending and descending order. Read the rest of this entry »

Python – Slice List example

Posted on Updated on

In our previous article, we came with examples to iterate list and iterate dictionary. Slicing is an important and commonly used feature in Python. By using slice operation at list, we can get sub-list from original list. In this tutorial we will demonstrate different ways to slice list.

1)  Most popular way to slice List

Read the rest of this entry »

Python – Iterate Dictionary example

Posted on

Dictionary is data structure which store data in key-value pair and widely used in Python programming language. In our previous tutorial, we came up with the example to iterate a list. In this blog, we will demonstrate the examples to iterate dictionary in various ways.

1) Iterate dictionary using keys()

Read the rest of this entry »

Python – Iterate List example

Posted on

List is widely used data structure in Python. In this tutorial, we will be demonstrating examples to iterate list using for loop and while loop.

1) Iterate List using for loop

Read the rest of this entry »