Python String

Python f-strings - PEP 498 - Literal String Interpolation — step-by-step Python tutorial on Progressive Robot

Python f-strings – PEP 498 – Literal String Interpolation

URL: https://www.progressiverobot.com/python-f-strings-literal-string-interpolation/ Python f-strings or formatted strings are the new way to format strings. This feature was introduced in Python 3.6 under PEP-498. It's also called literal string interpolation. Why do we need f-strings? Python provides various ways to format a string. Let's quickly look at them and what are the issues they have. % […]

Read more
Python String contains — step-by-step Python tutorial on Progressive Robot

Python String contains

Learn how to check if one Python string contains another using the __contains__() method. This case-sensitive instance method returns True or False based on whether the specified substring is present. Explore simple examples and user-input scenarios to understand its application. Enhance your Python string-handling skills with practical demonstrations and clear explanations.

Read more
Python String isalnum() — step-by-step Python tutorial on Progressive Robot

Python String isalnum()

URL: https://www.progressiverobot.com/python-string-isalnum/ Python string isalnum() function returns True if it's made of alphanumeric characters only. A character is alphanumeric if it's either an alpha or a [number](/community/tutorials/python-numbers). If the string is empty, then isalnum() returns False. !python string isalnum() Python string isalnum() example s = 'HelloWorld2019' print(s.isalnum()) Output: True s = 'Hello World 2019' print(s.isalnum()) […]

Read more
Python String replace() — step-by-step Python tutorial on Progressive Robot

Python String replace()

URL: https://www.progressiverobot.com/python-string-replace/ Python string replace() function is used to create a string by replacing some parts of another [string](/community/tutorials/python-string). Python String replace Python String replace() function syntax is: str.replace(old, new[, count]) The original string remains unmodified. The new string is a copy of the original string with all occurrences of substring _old_ replaced by _new_. […]

Read more
How To Use Python Raw String — step-by-step Python tutorial on Progressive Robot

How To Use Python Raw String

URL: https://www.progressiverobot.com/python-raw-string/ Introduction You can create a raw string in Python by prefixing a string literal with r or R. Python raw string treats the backslash character (\) as a literal character. Raw string is useful when a string needs to contain a backslash, such as for a regular expression or Windows directory path, and […]

Read more
Python String Append — step-by-step Python tutorial on Progressive Robot

Python String Append

URL: https://www.progressiverobot.com/python-string-append/ Python string object is immutable. So every time we use + operator to concatenate two strings, a new string is created. If we have to append many strings, using + operator will unnecessarily create many temporary strings before we have the final result. Python String Append Let's look at a function to concatenate […]

Read more
How To Work with Unicode in Python — step-by-step Python tutorial on Progressive Robot

How To Work with Unicode in Python

The tutorial will cover the basics of Unicode in Python and how Python interprets Unicode characters. It covers the concepts of unicodedata and how to use this module to convert UTF-8 to ASCII. By the end of this tutorial readers will have a strong fundamental understanding of Unicode in Python which would help solve internationalization problems in code.

Read more
Python String Substring — step-by-step Python tutorial on Progressive Robot

Python String Substring

A substring is the part of a string. Python string provides various methods to create a substring, check if it contains a substring, index of substring etc. In this tutorial, we will look into various operations related to substrings.

Read more
CHAT