Working with Raw Strings in Python
Quick Overview In Python, raw strings are string literals prefixed with the letter r. They are used to treat backslashes (/) as literal characters, ignoring their escape sequence…
Python: 8 Ways to Concatenate Strings
String concatenation is the process of combining two or more strings into a single string. This pithy, example-based article shows you a couple of different ways to concatenate…
Python: Count the frequency of each word in a string (2 ways)
This succinct and straight-to-the-point article will walk you through some different ways to find the frequency (the number of occurrences) of each word in a string in Python….
Python: 3 ways to convert a string to a hexadecimal value
In Python and the world of software development, a hexadecimal value (or hex value) is a representation of a number using base-16 digits and alphabets. It consists of…
Python: 3 ways to compare 2 strings ignoring case sensitivity
Ignoring case when comparing strings is useful in scenarios where you want to perform case-insensitive matching, especially when validating user input (e.g., email addresses, usernames, captchas, coupon codes)….
Python: How to check if a string is empty
Python does not have built-in methods or attributes like is_empty() or is_empty specifically designed to check whether a string is empty. However, there are other ways to achieve…
Python: 4 Ways to Generate Random Strings
In modern Python projects, random strings are commonly used for multifarious purposes, such as originating identifiers (IDs) for database records, making secure passwords or authentication tokens, uniquely naming…
Python: 4 Ways to Count Words in a String
This practical, example-based article will walk you through a couple of different ways to count the number of words in a given string in Python. Let’s get right…
Python: Capitalize the First Letter of each Word in a String
This concise and straightforward article will show you four different ways to capitalize the first letter of each word in a given string in Python. Using the title()…
Python: 4 Ways to Declare a Multiline String (Block String)
This concise, straight-to-the-point article shows you a couple of different ways to declare a multiline string (block string) in Python. Using Triple Quotes (Recommended) You can use triple…