Strings and Strings functions in Python.

Strings and Strings functions in Python.

·

2 min read

Strings Functions in Python.

First we will see what is a string in python?

String: In Python, a string is a sequence of characters enclosed within either single quotes (‘ ’), double quotes

(“ ”), or triple quotes (“”” ””” or ‘’’ ‘’’).

Now let’s see How to print normal string?

As Python provides / offers a wide range of string functions and manipulations. Let’s go through one-by-one.

1)Concatenation: Combining strings using the ‘+’ operator.

Example:-

2)Length: Getting the length of a string using len() function.

Example:-

3)Accessing Characters: Accessing individuals characters of a string using index notation.

Example:-

4)Slicing: Extracting a portion of a string using slicing notation.

Example:-

5)Lowercase and Uppercase: Converting strings to lowercase or uppercase.

Example:-

6)Splitting: Breaking a string into a list of substrings based on a delimiter.

Example:-

Here the word delimiter means is a character or sequence of characters used to separate or define boundaries between text or data elements.

7)Stripping: Removing leading and trailing whitespace characters.

Example:-

8)Replacing: Replacing occurrences of a substring within a string.

Example:-

9)Finding: Finding the index of the first occurrence of a substring within a string.

Example:-

10)Formatting: Creating formatted strings using the format() method or f-strings.

Example:-

11)Count: Can be able to count repeated words in a string with the help of count() function.

Example:-

These are just a few examples, there are many string functions and manipulations available in Python.

Thanks for reading ;)…

Follow my Instagram handle:-

https://www.instagram.com/yashpale_?igsh=MmVlMjlkMTBhMg==