Working with Strings in Python

Strings in Python are sequences of characters that are enclosed in either single or double quotation marks. For example, ‘Sling’ and “Academy” are both strings. Strings can be used to store and manipulate text data.

This series of tutorials is all about strings in Python, from basic to advanced topics.

1 The modern Python strings cheat sheet

2 The modern Python regular expressions cheat sheet

3 Python: 7 Ways to Find the Length of a String

4 Python String Slicing: Tutorial & Examples

5 4 Ways to Format a String in Modern Python

6 Python: Remove leading/trailing whitespace from a string

7 Python: 5 Ways to Reverse a String

8 Python: 8 Ways to Concatenate Strings

9 Python: 5 ways to check if a string contains a substring

10 Python: Converting a string to lowercase/uppercase

11 Python: 4 Ways to Convert a String into a List

12 Python: 4 Ways to Declare a Multiline String (Block String)

13 Python: Capitalize the First Letter of each Word in a String

14 Python: How to check if a string is empty

15 Python: 4 Ways to Count Words in a String

16 Python: 3 ways to compare 2 strings ignoring case sensitivity

17 Working with Raw Strings in Python

18 Working with the str.replace() method in Python

19 Python: 4 Ways to Remove Substrings from a String

20 Python: Remove non-alphanumeric characters from a string

21 Python: 3 ways to convert a string to a URL slug

22 Python: Converting a string to bytes and vice versa

23 Python: How to Convert a String to Character Codes

24 Python: 2 ways to remove multiple consecutive whitespaces

25 Python: 3 Ways to Convert a String to Binary Codes

26 2 ways to get the size of a string in Python (in bytes)

27 Python: Convert character to Unicode code point and vice versa

28 How to base64 encode/decode a string in Python

29 Python: 3 Ways to Add Leading Zeros to a String

30 Python: 3 Ways to Check If a String Is a Valid URL

31 Python: 3 ways to extract all URLs from text

32 Python: 3 Ways to Get File Name and Extension from URL

33 Python: Get Hostname and Protocol from a URL

34 Python: How to Algin a String (Left, Right, and Center)

35 Python: How to Reverse the Order of Words in a String

36 Python: Get a list of unique words/characters from a string

37 Python: Replace unwanted words in a string with asterisks

38 Python: 3 ways to convert a string to a hexadecimal value

39 Python: 4 Ways to Generate Random Strings

40 Python: Count the frequency of each word in a string (2 ways)

41 Python: 4 Ways to Generate Random Color Codes

42 Python: 3 Ways to Validate Phone Numbers

43 Python: 5 ways to remove HTML tags from a string

44 Python: How to unescape HTML entities in a string

45 Python: 3 ways to remove empty lines from a string

46 Python: 3 Ways to Validate an Email Address

47 Python: How to define a regex-matched string type hint

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments