Year: 2021

How To Remove All Non-Alphabet Characters From A String?

💡 Summary: This blog explores the steps to remove all non-alphabet characters from a given string. The ‘re’ module in Python provides regular expression operations, to process text. One uses these operations to manipulate text in strings. The compile() method in conjunction with the sub() method can remove all non-alphabet characters from a given string. Note: …

How To Remove All Non-Alphabet Characters From A String? Read More »

Creating, Reading & Updating A Config File with Python

Subtitle: Avoid Hard-Coded Data While Making Your (And Others) Life Easier When the subject of config, or configuration, files comes up there is often confusion on what they are, how to read them, and the benefits that come from their use. In this article, we will cover what config files are before introducing the Python …

Creating, Reading & Updating A Config File with Python Read More »

How to Print a String Without ‘\n’ in Python

Strings, Printing and ‘\n’ The printing of a basic string is probably the first program the majority of people, myself included, write in Python –  does print(‘hello world’) sound familiar? From the outset we know the principle is simple, we can pass our string through the print() function and the output will be displayed in …

How to Print a String Without ‘\n’ in Python Read More »

Python Set clear()

Python’s set.clear() method removes all elements from this set. All variables that refer to this set object will refer to an empty set after calling the method. Here’s a minimal example where you remove three elements from a set at once by means of the s.clear() method: Syntax Let’s “dive” into the formal syntax of …

Python Set clear() Read More »

Python Set copy()

Python’s set.copy() method creates and returns a flat copy of this set. Here’s a minimal example where you copy a set with two integers and a string value: Syntax Let’s dive into the formal syntax of the set.copy() method. set.copy() Argument Data Type Explanation – – – The set.copy() method doesn’t take any argument. If …

Python Set copy() Read More »