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. …
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
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.