Methods and Functions
Methods and Functions
• find(...)
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found, such that sub is
contained within S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
Return -1 on failure.
• index(...)
S.index(sub[, start[, end]]) -> int
Same as find(...) but raises ValueError when the substring is not found.
• isalnum(...)
S.isalnum() -> bool
Return True if all characters in S are alphanumeric and there is at least
one character in S, False otherwise.
• isalpha(...)
S.isalpha() -> bool
Return True if all characters in S are alphabetic and there is at least one
character in S, False otherwise.
• isdigit(...)
S.isdigit() -> bool
Return True if all characters in S are digits and there is at least one
character in S, False otherwise.
• islower(...)
S.islower() -> bool
Return True if all cased characters in S are lowercase and there is at least
one cased character in S, False otherwise.
• isupper(...)
S.isupper() -> bool
Return True if all cased characters in S are uppercase and there is at least
one cased character in S, False otherwise.
• join(...)
S.join(iterable) -> str
Return a string which is the concatenation of the strings in the iterable.
The separator between elements is S.
• lower(...)
S.lower() -> str
Return a copy of the string S converted to lowercase.
• lstrip(...)
S.lstrip([chars]) -> str
Return a copy of the string S with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
• replace(...)
S.replace(old, new[, count]) -> str
2
• rstrip(...)
S.rstrip([chars]) -> str
Return a copy of the string S with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
• split(...)
S.split(sep=None) -> list of strings
Return a list of the words in S, using sep as the delimiter string.
If sep is not specified or is None, any whitespace string is a separator and
empty strings are removed from the result.
• strip(...)
S.strip([chars]) -> str
Return a copy of the string S with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
• upper(...)
S.upper() -> str
Return a copy of S converted to uppercase.
• clear(...)
L.clear() -> None
Remove all items from L.
• copy(...)
L.copy() -> list
Return a shallow copy of L.
• count(...)
L.count(value) -> integer
Return number of occurrences of value.
• extend(...)
L.extend(iterable) -> None
Extend list by appending elements from the iterable.
• index(...)
L.index(value, [start, [stop]]) -> integer
Return first index of value. Optional arguments start and end are
interpreted as in slice notation (L[start:end]).
Raises ValueError if the value is not present.
• insert(...)
L.insert(index, object) -> None
Insert object before index.
• pop(...)
L.pop([index]) -> item
Remove and return item at index (default last).
3
• remove(...)
L.remove(value) -> None
Remove first occurrence of value.
Raises ValueError if the value is not present.
• reverse(...)
L.reverse() -> None
Reverse. *IN PLACE*
• sort(...)
L.sort(key=None, reverse=False) -> None
Stable sort. *IN PLACE*
Random module:
• choice(...)
random.choice(seq) -> element
Choose a random element from a non-empty sequence seq.
• randint(...)
random.randint(a, b) -> int
Return random integer in range [a, b], including both end points.
• random(...)
random.random() -> float
Return random float in range [0.0, 1.0], including 0.0 and excluding 1.0.
• shuffle(...)
random.shuffle(L) -> None
Shuffle list x in place, and return None.
Builtin functions:
• chr(...)
chr(i) -> str
Return a Unicode string of one character with ordinal i.
• len(...)
len(obj) -> int
Return the number of items in the object obj.
• max(...)
max(iterable) -> item
max(arg1, arg2) -> value
With a single iterable argument, return its biggest item.
With two or more arguments, return the biggest argument.
• min(...)
min(iterable) -> value
min(arg1, arg2) -> value
With a single iterable argument, return its smallest item.
With two or more arguments, return the smallest argument.
• ord(...)
ord(c) -> int
Return the Unicode code point for a one-character string c.
• sum(...)
4