|
[[...], [...], [...], ...]
|
list of list
|
|
list_of_list[...][...]
|
index elements in a list of list
|
|
dict{key : [..., ...]}
|
values of a dictionary can be a list
|
|
[dict1, dict2]
|
list of dictionary
|
|
list + list
|
add lists
|
|
list * int
|
multiply the list
|
[i for i in range(10)]
[i for i in range(31) if i % 2 == 0]
[[m.upper(), len(m)] for m in msg_lst]
[seq[i:i+width] for i in range(0, len(seq), width)]
list[start:stop:step] |
list sciling (tranche)
|
enumerate(list) |
return positions and items
|
list.index(item) |
return the position of the item
|
list.count(item) |
returns the number of times that element appears in the list
|
list(string) |
convert a string to a list one by one charcter
|
string.split(sep) |
convert a string to a list with a separator
|
'sep'.join(list) |
convert a list to a string
|
len(list) |
length of lists
|
max(list) |
find the maximun
|
min(list) |
find the minimun
|
sum(list) |
calculate the sum
|
list.sort(reverse=) |
sort the elements of a list in-place. reverse False from smallest to largest values; alphabetic order possible
|
sorted(list, reverse=) |
create a new sorted list without modifying the original list; alphabetic order possible
|
list.reverse() |
reverse the elements of a list in-place
|
reversed(list) |
create a new reversed list without modifying the original list
|
list.append(item) |
add an element to the end of lists
|
list.insert(item, pos) |
insert an element at a position of lists
|
list.remove(item) |
remove an item from lists; remove only one first element.
|
list.pop() |
remove and return the last element
|
del list[pos] |
remove the item by its position idenx
|
range(start,stop,step) |
similar to lists, but immutable. stop at n-1
|
set(list) |
remove the duplicated elements
|
list[start:stop:step] step 1 by default; stop at n-1 even if negative indexlist[:] create a new list. lst2 = lst1 creates a reference to the original list with the same ID'sep'.join(list) cannot combine a list containing only number (int & float). [str(i) for i in list]list.remove(item) If there're duplicated elements, it remove only the first elementrange(start,stop,step) stop could be higher than start with a negative step
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.