String Operations

From Sustainability Methods
Revision as of 09:21, 18 September 2024 by Gustavo (talk | contribs) (Created page with "In Python, strings are a sequence of characters used to store and manipulate text. Python provides many built-in methods to perform common string operations, which are especia...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In Python, strings are a sequence of characters used to store and manipulate text. Python provides many built-in methods to perform common string operations, which are especially useful in data analysis for cleaning, transforming, and analyzing text data. Below are some of the most commonly used string operations.

1. Converting to Lowercase and Uppercase

You can convert a string to all lowercase or uppercase characters using the lower() and upper() methods.

text = "Wiki Methods"
print(text.lower())  # Output: "hello world"
print(text.upper())  # Output: "HELLO WORLD"

The output will be respectively:

wiki methods
WIKI METHODS