Lists - Built-In Functions and Methods
Lists - Built-In Functions and Methods
1
cmp(list1, list2)
2 len(list)
3
max(list)
4 min(list)
5
list(seq)
1
list.append(obj)
2 list.count(obj)
Returns count of how many times obj occurs in list
3
list.extend(seq)
4 list.index(obj)
5
list.insert(index, obj)
6 list.pop(obj=list[-1])
7
list.remove(obj)
8 list.reverse()
9
list.sort([func])
1
cmp(tuple1, tuple2)
2 len(tuple)
3
max(tuple)
4 min(tuple)
5
tuple(seq)
1
cmp(dict1, dict2)
2 len(dict)
Gives the total length of the dictionary. This would be equal to the number of items in the
dictionary.
3
str(dict)
4 type(variable)
Returns the type of the passed variable. If passed variable is dictionary, then it would return
a dictionary type.
1 dict.clear()
2
dict.copy()
Create a new dictionary with keys from seq and values set to value.
4 dict.get(key, default=None)
5
dict.has_key(key)
6 dict.items()
7
dict.keys()
8 dict.setdefault(key, default=None)
Similar to get(), but will set dict[key]=default if key is not already in dict
9
dict.update(dict2)
10 dict.values()