Python language basics 47: 2 ways to reverse the elements in a list

Introduction

In the previous post we looked at 2 ways to sort the elements in a list. The sort function operated directly on the list and the sorted function accepted another list as an argument and returned a new list. You could use the sorted function in case you need an independent sorted list and leave the source intact.

In this post we’ll look at two ways to reverse the elements in a list.

Read more of this post

Python language basics 46: 2 ways to sort lists

Introduction

In the previous post we looked 3 ways to copy a list in Python: slicing, the copy function and the list constructor. We said that they all created shallow copies of the source list. Therefore beware of the implications of that if the list to be copied has mutable objects.

In this object we’ll look at 2 ways to sort the objects within a list.

Read more of this post

Python language basics 45: 3 ways to copy a list

Introduction

In the previous post we discussed how to slice a collection. We saw how you could create another collection from the original by extracting a range of it.

In this post we’ll describe various ways to create a copy of a list.

Read more of this post

Python language basics 44: slicing a list

Introduction

In the previous post we looked at the index function for collections. We saw how it helped find the location of an object by returning the position as an integer.

In this post we’ll look at how to slice a list.

Read more of this post

Python language basics 43: find the position of an element in a collection

Introduction

In the previous post we looked at how to remove elements from a collection in Python. We discussed the del keyword and the remove function. The del keyword works based on indexes whereas the remove function accepts the object to be removed.

In this post we’ll look at the index function which helps us locate an element in a collection.

Read more of this post

Python language basics 42: 2 ways to remove elements from a collection

Introduction

In the previous post we looked at a couple of ways to insert or append elements to a collection. We saw the usage of the insert, append and extend functions. We also discussed how the + and += operators affect a list.

In this post we’ll look at the exact opposite, i.e. how to remove an item from a collection.

Read more of this post

Python language basics 41: 4 ways to insert new elements into a collection

Introduction

In the previous post we looked at negative indexes for collections. We saw how they could be used to access elements from the tail of the list. An index of -1 will help you get to the last element of a collection regardless of its size.

In this post we’ll look at 4 ways to insert elements into a collection.

Read more of this post

Python language basics 40: negative indexers for collections

Introduction

In the previous post we looked at string formatting at a very basic level. We saw some elementary examples of the format function which can be applied to a given format and one or more input variables. We discussed the role of placeholder variables in the format and how they can be used different ways.

In this post we’ll look at negative indexes for collections.

Read more of this post

Python language basics 39: string formatting

Introduction

In the previous post we looked at the usage of the partition function. It can be applied to strings and it breaks up strings into 3 parts: to the left and the right of the partitioner and the partitioner itself. It is similar to the split function.

In this post we’ll briefly go through formatting strings with the format function.

Read more of this post

Python language basics 38: how to partition a string

Introduction

In the previous post we looked at the split function that operates on strings. We saw how it could split up a string into its elements using a delimiter.

In this post we’ll look at the partition function of the string type.

Read more of this post

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

Bite-size insight on Cyber Security for the not too technical.

%d bloggers like this: