0% found this document useful (0 votes)
2 views4 pages

CS-python Methods For List, String, Dictionary

Uploaded by

mymeerat
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

CS-python Methods For List, String, Dictionary

Uploaded by

mymeerat
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

List Methods

Method Syntax Parameter Return Error Remarks


append [Link](x) x None AttributeError Adds end
extend [Link](iterable) iterable None TypeError Adds
multiple
insert [Link](i,x) i,x None TypeError Insert
position
remove [Link](x) x None ValueError First
occurrence
pop [Link]([i]) i element IndexError Remove
index
clear [Link]() - None - Remove
all
index [Link](x) x int ValueError Find index
count [Link](x) x int - Count
sort [Link]() key,reverse None TypeError Sort
reverse [Link]() - None - Reverse
copy [Link]() - list - Shallow
copy

String Methods
Method Syntax Parameter Return Error Remarks
lower [Link]() - str - Lowercase
upper [Link]() - str - Uppercase
strip [Link]() chars str - Trim
split [Link](sep) sep list - Split
join [Link](it) iterable str TypeError Join
replace [Link]() old,new str - Replace
find [Link]() sub int - -1 if
absent
index [Link]() sub int ValueError Error if
absent
startswith [Link]() prefix bool - Check
start
endswith [Link]() suffix bool - Check end
isalpha [Link]() - bool - Alphabet
isdigit [Link]() - bool - Digits
Dictionary Method
Method Syntax Parameter Return Error Remarks
keys [Link]() - dict_keys - Keys
values [Link]() - dict_values - Values
items [Link]() - dict_items - Pairs
get [Link](key) key value - Safe
access
update [Link]() dict None TypeError Merge
pop [Link](key) key value KeyError Remove
popitem [Link]() - tuple KeyError Last pair
clear [Link]() - None - Clear
setdefault [Link]() key value - Insert
copy [Link]() - dict - Shallow
copy

You might also like