How to Insert a String into Another String at a Given Index in Python?Β 

Let’s start this article with a quick question to understand your understanding of strings. πŸ’¬ Question: Can the string objects be modified in Python? What do you think? Well, the fact is String objects are immutable. They cannot be modified. Consider the below example :  Output: Now you might say, replacement operations and insertion operations … Read more

How to Create a List of the Alphabet

Problem Formulation and Solution Overview In this article, you’ll learn how to create a list containing the alphabet in Python. To make it more fun, we have the following running scenario: Ms. Smith, a Grade 2 teacher at Oakwood Public School, wants to strengthen her student’s Alphabet skills and needs your help. She would like … Read more

How to Get the Standard Deviation of a Python List?

This article shows you how to calculate the standard deviation of a given list of numerical values in Python. Definition and Problem Formulation The standard deviation is defined as the square root of the variance. In case you’ve attended your last statistics course a few years ago, let’s quickly recap the definition of variance: variance … Read more

How to Generate a Sequence of Numbers

Problem Formulation and Solution Overview In this article, you’ll learn how to create a sequence of numbers in Python. To make it more fun, we have the following running scenario: Lux Lottery has decided to create a new Quick-Pick game called Lux-150. This game is based on seven (7) random numbers between 1 and 150 … Read more

How to Convert an Integer List to a String List in Python

The most Pythonic way to convert a list of integers ints to a list of strings is to use the one-liner strings = [str(x) for x in ints]. It iterates over all elements in the list ints using list comprehension and converts each list element x to a string using the str(x) constructor. This article … Read more

How to Delete an Object From a List in Python? 5 Ways

A Python list is a collection of objects that are indexed, ordered, and mutable. There are several different ways to delete a list item. We’ll first look at how we can delete single items from a list. And then finish with removing multiple objects. Method 1 – remove() Python list.remove() is a built-in list method … Read more

How to Remove a List Element by Value in Python?

Problem Formulation Given a Python list and an element (value). How to remove the element (value) from the given list? Here’s an example of what you want to accomplish: Given: List [1, 2, 99, 4, 99] Element 99 Return: List [1, 2, 4, 99] An alternative would return the list with the element (value) 99 … Read more