Category Python String

Strings – you use it in every program, just like any other programming language. Learn about Strings in Python and how to manipulate them in the Pythonic way.

Python replace() function

Python replace() function

Calling `”Python python PYTHON”.replace(“python”, “Ruby”)` changes only the lowercase match. I appreciate the `count` argument because it caps how many matches change. Pass the old and new text to `str.replace()` and check the returned string. Compare that returned string with…

Understanding Python f-string

Understanding Python f-string

Debug prints all repeat the same chore, because the variable name gets typed once as a label and once as the value. The f-string shorthand prints both from a single expression, so the label can never drift out of sync…

Python String join() function

Python String join() function

Every list of strings eventually needs to become one string, and the line that does it reads backwards. The separator calls the method while the list supplies the items, so a comma-joined row comes out as a one-liner once you…

What does {:02d} mean in Python?

What does {:02d} mean in Python?

String formatting is a very essential element of Python programming. Usually, we get strings that are not completely in the format that we want them to be in. Converting the string in the desired format is called string formatting. To…

How To Use StringIO In Python3?

How To Use StringIO In Python3?

The StringIO is a class that comes under the scope of the ‘io’ module. This module mainly deals with the I/O operation and tasks. The different sections related to I/O are files, I/O streams, buffers, and other files handled with…