The document outlines built-in functions and methods for strings, lists, and dictionaries in Python. It provides a comprehensive list of functionalities for each data type, including string manipulation methods like 'str()', 'count()', and 'replace()', as well as list methods such as 'append()', 'sort()', and dictionary methods like 'get()' and 'keys()'. This serves as a reference for Python programming, detailing how to manipulate these common data structures.
The document outlines built-in functions and methods for strings, lists, and dictionaries in Python. It provides a comprehensive list of functionalities for each data type, including string manipulation methods like 'str()', 'count()', and 'replace()', as well as list methods such as 'append()', 'sort()', and dictionary methods like 'get()' and 'keys()'. This serves as a reference for Python programming, detailing how to manipulate these common data structures.
Converts the first letter of each word to uppercase
string.title() and the rest to lowercase ( title format )
string.count(Sub_string) Returns the number of occurrences of a substring
in the string
string.split(delimiter) Splits the string into a list based on a delimiter
(default is whitespace)
string.lower() Converts all characters to lowercase
string.upper() Converts all characters to uppercase
string.strip() Removes leading and trailing whitespace
string.replace(Str1 , Str2) Replaces a substring with another substring
string.find(Sub_string) Returns the index of the first occurrence of a
substring. Returns -1 if not found
string.startswith(prefix) Checks if the string starts with the specified prefix
Returns True if the string starts with the prefix, otherwise False string.endswith(suffix) Checks if the string ends with the specified suffix Returns True if the string starts with the prefix, otherwise False
string.isdigit() Checks if all characters in the string are digits
Returns True if the string contains only digits, otherwise False
Lists Methods :
list.append(elem) Adds an element to the end of the list
list.insert( position , elem) Inserts an element at a specified index
list.remove(elem) Removes the first occurrence of a specified
element
list.pop(elem) Removes and returns the element at the specified
index (default is last element)
list.index(elem) Returns the index of the first occurrence of a
specified element
list.sort() Sorts the list in place (modifies the original list)
list.reverse() Reverses the elements of the list in place
len(list) Returns the length (number of elements) of the
list
sum(list) Returns the sum of all elements in the list
(if they are numeric)
Dictionary Methods :
dict.get(key) Returns the value for the specified key, or a
default value if the key doesn't exist dict.keys() Returns a view object displaying a list of all keys in the dictionary
dict.values() Returns a view object displaying a list of all values
in the dictionary
dict.items() Returns a view object displaying a list of
key-value pairs in the dictionary
del dict [key] Removes a key-value pair from the dictionary
APznzabQWkwKaG MMt2BqKWG4o2gPw9rEhD41Adg8VtkG99p65at0kD0Otvy6dPjXIcG0Is2VwbIABD6qBQ5JsXwkKAXkUGqh8nx4FWO0YszkAYftl0Y1GTipAEuKK6Mz4 GRE 7vT8kDmuB3Ff6IhK8KAJkEGuvaDDIa16B4zJoC NriSyY4yYgNhkzDMaR4Lom2InUuAE4zQuGcmE2cgSUbdkkaHqs8mpVkj5z071