- Python
list.index()
will give the location of the first occurence of an element in a list. It can be useful for getting the part of a list before and after a certain marker - Python
list.count(a)
will count occurences ofa
in the list [1,2,3]*3
will evaluate to[1,2,3,1,2,3,1,2,3]
frozenset
is a hashable but immutable type ofset
. In other words,frozenset
can not be modified after creation but can be used for e.g. dict keysmath.gcd(*args)
for greatest divisor andmath.lcm(*args)
for least common multiplemath.prod(iterable)
. No need fornp.prod
and works on all iterables