Mindmap
String Manipulation
Inhalt der Mindmap
String Manipulation
Traversing a String
- Definition
- Traversing a string in Python involves accessing each character within the string, one after the other
- Techniques
- for loop
- while loop
- Definition
String Operators
- Concatenation
- +
- Eg. 'tea' + 'pot'
- 'teapot'
- Eg. 'tea' + 'pot'
- +
- Replication
- *
- Eg. 'go' * 3
- 'gogogo'
- Eg. 'go' * 3
- *
- Membership operators
- in
- The in operator in Python is a membership operator that checks if a value exists within a sequence, such as a list, tuple, string, or dictionary
- Eg. 'a' in 'heya'
- Returns True
- Eg. 'a' in 'heya'
- The in operator in Python is a membership operator that checks if a value exists within a sequence, such as a list, tuple, string, or dictionary
- not in
- The not in operator in Python checks if a value is not present in a sequence (like a list, tuple, string, or set). It returns True if the value is not found and False if it is found.
- Eg. 'a' not in 'heya'
- Returns False
- Eg. 'a' not in 'heya'
- The not in operator in Python checks if a value is not present in a sequence (like a list, tuple, string, or set). It returns True if the value is not found and False if it is found.
- in
- Comparison Operator
- Compares two strings on the basis of ASCII values of the characters using <, >, <=, >=, ==, !=
- Example
- "a" == "a"
- Example
- Compares two strings on the basis of ASCII values of the characters using <, >, <=, >=, ==, !=
- Concatenation
String Slicing
- Definition
- String slicing in Python extracts a substring from a string. It uses the syntax string[start:stop:step]
- Example
- s[1:7:2]
- Definition
Built-in functions
- split()
- The split() method splits a string into a list.
- len()
- The len() function determine the number of items in an object
- capitalize()
- The capitalize() function that converts the first character of a string to uppercase and the rest of the characters to lowercase
- title()
- The title() converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
- lower()
- The lower() function that converts all uppercase characters in a string to lowercase
- upper()
- The upper() function that converts all lowercase characters in a string to uppercase
- count()
- The count() method returns the number of times a specified value appears in the string
- find()
- The find() method finds the first occurrence of the specified value. The find() method returns -1 if the value is not found.
- index()
- The index() method finds the first occurrence of the specified value. The index() method raises an exception if the value is not found
- endswith()
- The endswith() method in Python is used to check if a string ends with a specified suffix. It returns True if the string ends with the suffix, and False otherwise. The suffix can be a string or a tuple of strings.
- startswith()
- The startswith() used to check if a string begins with a specified prefix (substring).
- isalnum()
- The isalnum() function that checks if all characters in a string are alphanumeric, meaning they are either letters (a-z, A-Z) or numbers (0-9).
- isalpha()
- The isalpha() method checks if all characters in a given string are alphabetic.
- isdigit()
- The isdigit()used to check if all characters in a string are digits (0-9).
- isdigit()
- The isdigit() used to check if all characters in a string are digits (0-9).
- islower()
- The islower() method in Python checks if all characters in a string are lowercase
- isupper()
- The isupper() method in Python checks if all the alphabetic characters in a string are uppercase.
- isspace()
- The isspace() is used to check if all characters in a string are whitespace characters.
- lstrip()
- The lstrip() method removes any leading characters (space is the default leading character to remove)
- rstrip()
- Iit removes whitespace characters (spaces, tabs, newlines) from the end of the string.
- strip()
- To remove leading and trailing characters from a string.
- replace()
- The replace() is used to replace occurrences of a specified substring within a string with another substring.
- join()
- The join() method in Python is used to concatenate the elements of an iterable (such as a list, tuple, or set) into a single string with a specified delimiter placed between each element.
- partition()
- The partition() method splits the string into three parts at the first occurrence of the separator and returns a tuple containing the part before the separator, the separator itself, and the part after the separator.
- split()
Informationen
- Beschreibung
- Mindmap am String Manipulation, erstellt von Suja Nair am 16/05/2025.
- Erstellt von
- Suja Nair
- Aufrufe
- 1
- Bewertung