python string list dict set methods
python string list dict set methods
Returns centred string using optional value as fill Return no of times value is in string. Optional parameters
Convert first character to upper case and rest lowercase Convert string to lower case. More aggresive than lower() character. Space (" ") is default specify where to search in string
isspace isupper
Return true if all characters are whitespaces
Return true if all characters are upper case
istitle
Python join
Return true if string follows rules of a title (all words are
lowercase except the first letter of each word) STRING METHODS Join iterable elements to end of stiring
By @AbzAaron
@AbzAaron
Set Methods
Sets are unordered & mutable collections of
unique elements
union update
Return set containing items from original set & Update original set by adding items from
items from specified set(s) or iterable(s) another set or iterable
APPEND
Add single element to
end of list
CLEAR
Remove all Items from
list
COPY
Return shallow copy of
list
COUNT
Return count of an
element in list
EXTEND
Adds iterable elements
to end of list
INDEX
Return index of first element
in list matching given value
INSERT
Insert element to list at
given index
POP
Remove element at given
index and returns it
REMOVE
Remove first item from
list that has given value
REVERSE
Reverse the list
SORT
Sort elements of a list
PYTHON
Dictionary Methods
@AbzAaron
CLEAR
Remove all elements from Dictionary
COPY
Return copy of Dictionary
FROMKEYS
Return Dictionary with specified keys &
values
Optional Parameter: Value. This is what's set for all keys.
Default is None
GET
Return value of specified key
ITEMS
Return view object containing list of
key value pairs
KEYS
Return view object containing list of
keys
POP
Remove element with specified key
and return it
Optional Parameter: Defaultvalue. This is value to return if no key is
found in dictionary
POPITEM
Remove last inserted key value pair and
return as tuple
SETDEFAULT
Return value of item with specified key. If
key doesn't exist, insert with specified value
Optional Parameter: value. Default is None
UPDATE
Update dictionary with specified key
value pairs
VALUES
Return view objects containing list of
values