> ## Documentation Index
> Fetch the complete documentation index at: https://takeprofit.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Builtins

Built-in symbols of Indie language.

***

## Variables

**1. Constants**

[Navigate to const\_False](#const_False)

False

bool

Built-in Indie object (similar to Python's).

[Navigate to const\_None](#const_None)

None

NoneType

Built-in Indie object (similar to Python's).

[Navigate to const\_True](#const_True)

True

bool

Built-in Indie object (similar to Python's).

***

## Functions

### `abs()`

*function*

**1. Overloads**

abs

(x) -> int

Returns the absolute value of a number. It is a built-in Indie function (similar to Python's).

**parameters info**

x

int

required

Number on which the function will be calculated.

abs

(x) -> float

Returns the absolute value of a number. It is a built-in Indie function (similar to Python's).

**parameters info**

x

float

required

Number on which the function will be calculated.

***

### `enumerate()`

*function*

**1. Overloads**

enumerate

(iterable, start) -> enumerate\_t\[T]

Returns an enumerate object. Can be used with any iterable object (like lists or ranges).

**parameters info**

iterable

iterable\[T]

required

An iterable to enumerate.

start

int

default:
0

The start index.

***

### `len()`

*function*

**1. Overloads**

len

(x) -> int

Returns the length (the number of items) of an object. It is a built-in Indie function (similar to Python's).

**parameters info**

x

typing.Any

required

Value on which the function will be calculated.

***

### `max()`

*function*

**1. Overloads**

max

(x, y) -> int

Returns the largest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

int

required

First number to calculate the function.

y

int

required

Second number to calculate the function.

max

(x, y, z) -> int

Returns the largest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

int

required

First number to calculate the function.

y

int

required

Second number to calculate the function.

z

int

required

Third number to calculate the function.

max

(x, y) -> float

Returns the largest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

float

required

First number to calculate the function.

y

float

required

Second number to calculate the function.

max

(x, y, z) -> float

Returns the largest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

float

required

First number to calculate the function.

y

float

required

Second number to calculate the function.

z

float

required

Third number to calculate the function.

max

(l) -> int

Returns the largest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

l

list\[int]

required

List on which the function will be calculated.

max

(l) -> float

Returns the largest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

l

list\[float]

required

List on which the function will be calculated.

***

### `min()`

*function*

**1. Overloads**

min

(x, y) -> int

Returns the smallest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

int

required

First number to calculate the function.

y

int

required

Second number to calculate the function.

min

(x, y, z) -> int

Returns the smallest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

int

required

First number to calculate the function.

y

int

required

Second number to calculate the function.

z

int

required

Third number to calculate the function.

min

(x, y) -> float

Returns the smallest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

float

required

First number to calculate the function.

y

float

required

Second number to calculate the function.

min

(x, y, z) -> float

Returns the smallest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

x

float

required

First number to calculate the function.

y

float

required

Second number to calculate the function.

z

float

required

Third number to calculate the function.

min

(l) -> int

Returns the smallest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

l

list\[int]

required

List on which the function will be calculated.

min

(l) -> float

Returns the smallest of two or more arguments. It is a built-in Indie function (similar to Python's).

**parameters info**

l

list\[float]

required

List on which the function will be calculated.

***

### `round()`

*function*

**1. Overloads**

round

(number) -> int

Returns number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input. It is a built-in Indie function (similar to Python's).

**parameters info**

number

float

required

Number on which the function will be calculated.

round

(number, ndigits) -> float

Returns number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input. It is a built-in Indie function (similar to Python's).

**parameters info**

number

float

required

Number on which the function will be calculated.

ndigits

indie.Optional\[int]

default:
None

Rounding precision.

***

### `sum()`

*function*

**1. Overloads**

sum

(l, start) -> int

Sums start and the items of a list from left to right and returns the total. It is a built-in Indie function (similar to Python's).

**parameters info**

l

list\[int]

required

List on which the function will be calculated.

start

int

default:
0

Initial value to calculate sum of the list.

sum

(l, start) -> float

Sums start and the items of a list from left to right and returns the total. It is a built-in Indie function (similar to Python's).

**parameters info**

l

list\[float]

required

List on which the function will be calculated.

start

float

default:
0.0

Initial value to calculate sum of the list.

***

## Types

### `bool`

*type*

Built-in Indie type (similar to Python's).

**1. Methods**

[Navigate to method\_bool\_init](#method_bool_init)

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `bool` value, i.e. one of `True` or `False`. The argument is converted using the standard [Python's truth testing procedure](https://docs.python.org/3/library/stdtypes.html#truth).

**parameters info**

x

bool

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `bool` value, i.e. one of `True` or `False`. The argument is converted using the standard [Python's truth testing procedure](https://docs.python.org/3/library/stdtypes.html#truth).

**parameters info**

x

int

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `bool` value, i.e. one of `True` or `False`. The argument is converted using the standard [Python's truth testing procedure](https://docs.python.org/3/library/stdtypes.html#truth).

**parameters info**

x

float

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `bool` value, i.e. one of `True` or `False`. The argument is converted using the standard [Python's truth testing procedure](https://docs.python.org/3/library/stdtypes.html#truth).

**parameters info**

x

str

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `bool` value, i.e. one of `True` or `False`. The argument is converted using the standard [Python's truth testing procedure](https://docs.python.org/3/library/stdtypes.html#truth).

**parameters info**

x

NoneType

required

Value to cast from.

***

### `dict[K, V]`

*type*

Generic unordered data type that stores values by keys.

**1. Methods**

[Navigate to method\_dict\_getitem](#method_dict_getitem)

**getitem**

(key) -> V

Returns a dict value by key.

**parameters info**

key

K

required

Key of an item in the dict.

```py Example theme={null}
values: dict[str, int] = {}
values['a'] = 1
value = values['a']
```

> [!NOTE]
>
> Method `__getitem__` should never be called directly, instead `dict_obj[key]` syntax should be used.

[Navigate to method\_dict\_setitem](#method_dict_setitem)

**setitem**

(key, value) -> None

Assigns a value to dict\_obj\[key].

**parameters info**

key

K

required

Key of an item in the dict.

value

V

required

Value that will be put to the dict.

```py Example theme={null}
values: dict[str, int] = {}
values['a'] = 1
```

> [!NOTE]
>
> Method `__setitem__` should never be called directly, instead `dict_obj[key] = value` syntax should be used.

[Navigate to method\_dict\_delitem](#method_dict_delitem)

**delitem**

(key) -> None

Deletes an item from the dict by key.

**parameters info**

key

K

required

Key of an item in the dict.

```py Example theme={null}
values: dict[str, int] = {}
values['a'] = 1
del values['a']
```

> [!NOTE]
>
> Method `__delitem__` should never be called directly, instead `del dict_obj[key]` syntax should be used.

[Navigate to method\_dict\_len](#method_dict_len)

**len**

() -> int

Returns the number of items in a dict\[K, V].

```py Example theme={null}
values: dict[str, int] = {}
values['a'] = 1
size = len(values)
```

> [!NOTE]
>
> Method `__len__` should never be called directly, instead `len(dict_obj)` syntax should be used.

[Navigate to method\_dict\_bool](#method_dict_bool)

**bool**

() -> bool

Returns `True` if the dict is not empty.

```py Example theme={null}
values: dict[str, int] = {}
has_values = bool(values)
```

[Navigate to method\_dict\_contains](#method_dict_contains)

**contains**

(key) -> bool

Returns `True` if the dict contains the given key, otherwise `False`.

**parameters info**

key

K

required

Key of an item in the dict.

```py Example theme={null}
values: dict[str, int] = {}
values['a'] = 1
has_a = 'a' in values
```

> [!NOTE]
>
> Method `__contains__` should never be called directly, instead `key in dict_obj` syntax should be used.

[Navigate to method\_dict\_get](#method_dict_get)

get

(key, default) -> V

Returns the value for the key if it exists, otherwise returns the default value.

**parameters info**

key

K

required

Key of an item in the dict.

default

V

required

Default value that will be returned if the key is not found.

```py Example theme={null}
values: dict[str, int] = {}
value = values.get('a', 0)
```

[Navigate to method\_dict\_keys](#method_dict_keys)

keys

() -> list\[K]

Returns a snapshot list of the dictionary keys. Later mutations of the dictionary do not change the returned list.

[Navigate to method\_dict\_values](#method_dict_values)

values

() -> list\[V]

Returns a snapshot list of the dictionary values. Its indexes correspond to the list returned by `keys()` at the same moment.

[Navigate to method\_dict\_pop](#method_dict_pop)

pop

(key) -> V

Retrieves the value for the key and removes the item from the dict.

**parameters info**

key

K

required

Key of an item in the dict.

```py Example theme={null}
values: dict[str, int] = {}
values['a'] = 1
value = values.pop('a')
```

[Navigate to method\_dict\_clear](#method_dict_clear)

clear

() -> None

Removes all items from the dict.

```py Example theme={null}
values: dict[str, int] = {}
values['a'] = 1
values.clear()
```

[Navigate to method\_dict\_copy](#method_dict_copy)

copy

() -> dict\[K, V]

Returns a copy of the dict.

```py Example theme={null}
values: dict[str, float] = {}
values['open'] = 1.0
copied = values.copy()
```

```py Example theme={null}
values: dict[str, float] = {}
values['close'] = 42.0
close = values['close']
```

> [!NOTE]
>
> Supported key types are `str`, `int`, `bool`, and finite `float`. Values may be nested lists, dictionaries, and pairs.

***

### `float`

*type*

Built-in Indie type (similar to Python's).

**1. Methods**

[Navigate to method\_float\_init](#method_float_init)

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `float` number constructed from a number or a string.

**parameters info**

x

float

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `float` number constructed from a number or a string.

**parameters info**

x

int

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `float` number constructed from a number or a string.

**parameters info**

x

str

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `float` number constructed from a number or a string.

**parameters info**

x

bool

required

Value to cast from.

***

### `int`

*type*

Built-in Indie type (similar to Python's).

**1. Methods**

[Navigate to method\_int\_init](#method_int_init)

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns an `int` object constructed from a number or a string, or return 0 if no arguments are given.

**parameters info**

x

int

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns an `int` object constructed from a number or a string, or return 0 if no arguments are given.

**parameters info**

x

float

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns an `int` object constructed from a number or a string, or return 0 if no arguments are given.

**parameters info**

x

str

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns an `int` object constructed from a number or a string, or return 0 if no arguments are given.

**parameters info**

x

bool

required

Value to cast from.

***

### `list[T]`

*type*

Built-in Indie type (similar to Python's).

**1. Methods**

[Navigate to method\_list\_append](#method_list_append)

append

(x) -> None

Appends given param to the end of the list.

**parameters info**

x

T

required

New value that will be put to the list.

[Navigate to method\_list\_getitem](#method_list_getitem)

**getitem**

(i) -> T

Returns list element at given index.

**parameters info**

i

int

required

Index of an element in the list.

```py Example theme={null}
nums = [40, 41, 42, 43]
meaning_of_life = nums[2]  # returns 42 (this implicitly calls `nums.__getitem__(2)`)
```

> [!NOTE]
>
> Method `__getitem__` should never be called directly, instead `list_obj[key]` syntax should be used.

[Navigate to method\_list\_setitem](#method_list_setitem)

**setitem**

(i, x) -> None

Assigns value to some\_list\[key].

**parameters info**

i

int

required

Index of an element in the list.

x

T

required

New value that will be put to the list.

```py Example theme={null}
nums = [40, 41, 42, 43]
nums[2] = 100500  # this implicitly calls `nums.__setitem__(2, 100500)`
                  # and now `nums` are [40, 41, 100500, 43]
```

> [!NOTE]
>
> Method `__setitem__` should never be called directly, instead `list_obj[key] = value` syntax should be used.

[Navigate to method\_list\_delitem](#method_list_delitem)

**delitem**

(i) -> None

Delete an item from the list at the given index.

**parameters info**

i

int

required

Index of an element in the list.

```py Example theme={null}
nums = [40, 41, 42, 43]
del nums[2]  # this implicitly calls `nums.__delitem__(2)`
```

> [!NOTE]
>
> Method `__delitem__` should never be called directly, instead `del list_obj[key]` syntax should be used.

[Navigate to method\_list\_delslice](#method_list_delslice)

**delslice**

(start, stop, step) -> None

Delete a slice from the list.

**parameters info**

start

indie.Optional\[int]

default:
None

Starting index for slice. Can be omitted. See more examples below.

stop

indie.Optional\[int]

default:
None

Ending index for slice (not included). Can be omitted. See more examples below.

step

int

default:
1

Step between indexes of slice. Can be omitted. See more examples below.

```py Example theme={null}
nums = [40, 41, 42, 43]
del nums[0:2]  # this implicitly calls `nums.__delslice__(0, 2, 1)`
```

> [!NOTE]
>
> Method `__delslice__` should never be called directly, instead `del list_obj[slice]` syntax should be used.

[Navigate to method\_list\_len](#method_list_len)

**len**

() -> int

Returns the length (the number of items) of a list\[T].

```py Example theme={null}
nums = [40, 41, 42, 43]
len(nums)  # returns 4 (this implicitly calls `nums.__len__()`)
```

> [!NOTE]
>
> Method `__len__` should never be called directly, instead `len(list_obj)` syntax should be used.

[Navigate to method\_list\_bool](#method_list_bool)

**bool**

() -> bool

Returns `True` if the list is not empty.

[Navigate to method\_list\_contains](#method_list_contains)

**contains**

(x) -> bool

Returns `True` if the list contains the given value, otherwise `False`.

**parameters info**

x

T

required

Element to find in the list.

```py Example theme={null}
nums = [40, 41, 42, 43]
my_bool = 41 in nums  # this implicitly calls `nums.__contains__(41)`
```

> [!NOTE]
>
> Method `__contains__` should never be called directly, instead `val in lst` syntax should be used.

[Navigate to method\_list\_remove](#method_list_remove)

remove

(x) -> None

Removes the first item from list `s` where `s[i]` is equal to given param.

**parameters info**

x

T

required

Value that will be removed from the list

```py Example theme={null}
nums = [40, 41, 42, 40, 41, 42]
nums.remove(42)  # now `nums` are [40, 41, 40, 41, 42]
```

[Navigate to method\_list\_pop](#method_list_pop)

pop

(i) -> T

Retrieves the item at given index and also removes it from the list.

**parameters info**

i

int

default:
-1

Index of an element in the list.

```py Example theme={null}
nums = [40, 41, 42, 43]
meaning_of_life = nums.pop(2)  # now `nums` are [40, 41, 43], `meaning_of_life` is 42
```

[Navigate to method\_list\_insert](#method_list_insert)

insert

(i, x) -> None

Insert a value at the specified index.

**parameters info**

i

int

required

Index of an element in the list.

x

T

required

New value that will be put to the list.

```py Example theme={null}
nums = [40, 41, 42, 43]
nums.insert(2, 50)  # now `nums` are [40, 41, 50, 42, 43]
```

[Navigate to method\_list\_clear](#method_list_clear)

clear

() -> None

Remove all items from the list.

```py Example theme={null}
nums = [40, 41, 42, 43]
nums.clear()  # now `nums` is []
```

[Navigate to method\_list\_reverse](#method_list_reverse)

reverse

() -> None

Reverses the elements of the list in place.

[Navigate to method\_list\_index](#method_list_index)

index

(x) -> int

Returns index of the first occurrence of the item in the list. If not found returns `-1`.

**parameters info**

x

T

required

Element to find in the list.

[Navigate to method\_list\_getslice](#method_list_getslice)

**getslice**

(start, stop, step) -> list\[T]

Returns a slice of the list elements.

**parameters info**

start

indie.Optional\[int]

default:
None

Starting index for slice. Can be omitted. See more examples below.

stop

indie.Optional\[int]

default:
None

Ending index for slice (not included). Can be omitted. See more examples below.

step

int

default:
1

Step between indexes of slice. Can be omitted. See more examples below.

```py Example theme={null}
nums = [40, 41, 42, 43]
meaning_of_life = nums[1:3]  # returns [41, 42] (this implicitly calls `nums.__getslice__(1, 3, 1)`)
```

> [!NOTE]
>
> Method `__getslice__` should never be called directly, instead `list_obj[slice]` syntax should be used.

[Navigate to method\_list\_setslice](#method_list_setslice)

**setslice**

(start, stop, step, new\_list) -> None

Assigns given list to some\_list\[slice].

**parameters info**

start

indie.Optional\[int]

default:
None

Starting index for slice. Can be omitted. See more examples below.

stop

indie.Optional\[int]

default:
None

Ending index for slice (not included). Can be omitted. See more examples below.

step

int

default:
1

Step between indexes of slice. Can be omitted. See more examples below.

new\_list

list\[T]

required

List to get values from.

```py Example theme={null}
nums = [40, 41, 42, 43]
nums[1:3] = [50, 51, 52]  # this implicitly calls `nums.__setslice__(1, 3, 1, [50, 51, 52])`
                          # and now `nums` are [40, 50, 51, 52, 43]
```

> [!NOTE]
>
> Method `__setslice__` should never be called directly, instead `list_obj[slice] = other_list` syntax should be used.

[Navigate to method\_list\_copy](#method_list_copy)

copy

() -> list\[T]

Returns a copy of the list.

[Navigate to method\_list\_extend](#method_list_extend)

extend

(l) -> None

Extends the list by appending elements from the given list.

**parameters info**

l

list\[T]

required

List to concatenate with the current.

[Navigate to method\_list\_add](#method_list_add)

**add**

(l) -> list\[T]

Returns a concatenation of two lists.

**parameters info**

l

list\[T]

required

List to concatenate with the current.

```py Example theme={null}
nums1 = [40, 41]
nums2 = [42, 43]
nums3 = nums1 + nums2  # this implicitly calls `nums1.__add__(nums2)`
```

> [!NOTE]
>
> Method `__add__` should never be called directly, instead `list1 + list2` syntax should be used.

[Navigate to method\_list\_mul](#method_list_mul)

**mul**

(n) -> list\[T]

Returns a concatenation of the list with `n` its copies.

**parameters info**

n

int

required

How many copies of the list to concatenate.

```py Example theme={null}
nums1 = [40, 41]
nums2 = nums1 * 3  # this implicitly calls `nums1.__mul__(3)`
                   # and now `nums2` is [40, 41, 40, 41, 40, 41]
```

> [!NOTE]
>
> Method `__mul__` should never be called directly, instead `lst * n` syntax should be used.

```py Example theme={null}
# examples of list creation:
a = [1, 2, 3]  # `a` has type `list[int]`
b = [1, 2, 3, 4.2]  # `b` has type `list[float]`
c = ["a", "b", "c"]  # `c` has type `list[str]`
d = [(1, "a"), (2, "b"), (3, "c")]  # `d` has type `list[tuple[int, str]]`

e = [0, 1, 2, 3, 4, 5, 6, 7]
f = e[2:5]  # `f` is `[2, 3, 4]`
g = e[:5]  # `g` is `[0, 1, 2, 3, 4]`
h = e[2:]  # `h` is `[2, 3, 4, 5, 6, 7]`
i = e[:]  # `i` is a copy of `e`
j = e[1:7:2]  # `j` is `[1, 3, 5]`
k = e[5:2:-1]  # `k` is `[5, 4, 3]`
l = e[5::-1]  # `l` is `[5, 4, 3, 2, 1, 0]`
m = e[::-1]  # `m` is `[7, 6, 5, 4, 3, 2, 1, 0]`
```

***

### `NoneType`

*type*

Builtin Indie type (similar to Python's `NoneType` type).

***

### `range`

*type*

Represents a range of numbers that is used in `for` loops. It is a built-in Indie class (similar to Python's).

**1. Methods**

[Navigate to method\_range\_init](#method_range_init)

**init**

(stop) -> None

Class constructor (initializer for the data type).

**parameters info**

stop

int

required

Last value of the range (exclusive).

**init**

(start, stop, step) -> None

Class constructor (initializer for the data type).

**parameters info**

start

int

required

First value of the range.

stop

int

required

Last value of the range (exclusive).

step

int

default:
1

Step value of the range.

```py Example theme={null}
x = 0
for i in range(10):
    x += i
```

***

### `str`

*type*

Built-in Indie type (similar to Python's).

**1. Methods**

[Navigate to method\_str\_len](#method_str_len)

**len**

() -> int

Returns the length (the number of characters) of a `str`.

```py Example theme={null}
s = 'foobar'
len(s)  # returns 6 (this implicitly calls `s.__len__()`)
```

> [!NOTE]
>
> Method `__len__` should never be called directly, instead `len(str_obj)` syntax should be used.

[Navigate to method\_str\_init](#method_str_init)

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `str` version of object.

**parameters info**

x

int

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `str` version of object.

**parameters info**

x

float

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `str` version of object.

**parameters info**

x

str

required

Value to cast from.

**init**

(x) -> None

Cast constructor for built-in Indie type. Returns a `str` version of object.

**parameters info**

x

bool

required

Value to cast from.

[Navigate to method\_str\_contains](#method_str_contains)

**contains**

(s) -> bool

Returns `True` if the string contains the given substring, otherwise `False`.

**parameters info**

s

str

required

Substring to find in the string.

```py Example theme={null}
my_bool = 'cd' in 'abcdef'  # this implicitly calls `'abcdef'.__contains__('cd')`
```

> [!NOTE]
>
> Method `__contains__` should never be called directly, instead `str1 in str2` syntax should be used.

[Navigate to method\_str\_add](#method_str_add)

**add**

(s) -> str

Returns a concatenation of two strings.

**parameters info**

s

str

required

String to concatenate with the current.

```py Example theme={null}
str1 = 'ab'
str2 = 'cf'
str3 = str1 + str2  # this implicitly calls `str1.__add__(str2)`
```

> [!NOTE]
>
> Method `__add__` should never be called directly, instead `str1 + str2` syntax should be used.

[Navigate to method\_str\_mul](#method_str_mul)

**mul**

(n) -> str

Returns a concatenation of the string with `n` its copies.

**parameters info**

n

int

required

How many copies of the string to concatenate.

```py Example theme={null}
my_str = 'abc'
my_str2 = 'abc' * 3  # this implicitly calls `'abc'.__mul__(3)`
                     # and now `my_str2` is 'abcabcabc'
```

> [!NOTE]
>
> Method `__mul__` should never be called directly, instead `my_str * n` syntax should be used.

[Navigate to method\_str\_getitem](#method_str_getitem)

**getitem**

(i) -> str

Returns substring at given index.

**parameters info**

i

int

required

Index of an element in the string.

```py Example theme={null}
my_str = 'abc'
substr = my_str[1]  # returns "b" (this implicitly calls `my_str.__getitem__(1)`)
```

> [!NOTE]
>
> Method `__getitem__` should never be called directly, instead `my_str[key]` syntax should be used.

[Navigate to method\_str\_getslice](#method_str_getslice)

**getslice**

(start, stop, step) -> str

Returns a slice of the string elements.

**parameters info**

start

indie.Optional\[int]

default:
None

Starting index for slice. Can be omitted. See more examples below.

stop

indie.Optional\[int]

default:
None

Ending index for slice (not included). Can be omitted. See more examples below.

step

int

default:
1

Step between indexes of slice. Can be omitted. See more examples below.

```py Example theme={null}
my_str = '0123'
meaning_of_life = my_str[1:3]  # returns '12' (this implicitly calls `my_str.__getslice__(1, 3, 1)`)
```

> [!NOTE]
>
> Method `__getslice__` should never be called directly, instead `str_obj[slice]` syntax should be used.

[Navigate to method\_str\_capitalize](#method_str_capitalize)

capitalize

() -> str

Returns the string with the first letter capitalized.

[Navigate to method\_str\_center](#method_str_center)

center

(length, character) -> str

Centers the string within the specified width using a fill character.

**parameters info**

length

int

required

Length of the result string.

character

str

default:
" "

Fill character.

[Navigate to method\_str\_count](#method_str_count)

count

(value, start, end) -> int

Returns the count of non-overlapping occurrences of a substring within \[start, end].

**parameters info**

value

str

required

Value to search for.

start

int

required

Start index to search.

end

int

required

End index to search.

[Navigate to method\_str\_endswith](#method_str_endswith)

endswith

(value, start, end) -> bool

Returns `True` if the string ends with the suffix, otherwise `False`.

**parameters info**

value

str

required

Value to check if the end of the string equals.

start

int

required

Start index to check the end of the string.

end

int

required

End index to check the end of the string.

[Navigate to method\_str\_find](#method_str_find)

find

(value, start, end) -> int

Returns the lowest index where the substring is found.

**parameters info**

value

str

required

Value to search for.

start

int

required

Start index for searching.

end

int

required

End index for searching.

> [!NOTE]
>
> Use the `find()` method to get the position of a substring. To check for its presence, use the `in` operator.

[Navigate to method\_str\_index](#method_str_index)

index

(value, start, end) -> int

Returns the lowest index of the substring within \[start, end], raising an error if not found.

**parameters info**

value

str

required

Value to search for.

start

int

required

Start index for searching.

end

int

required

End index for searching.

[Navigate to method\_str\_isalpha](#method_str_isalpha)

isalpha

() -> bool

Returns `True` if the string contains only alphabetic characters and is not empty; otherwise, `False`.

[Navigate to method\_str\_islower](#method_str_islower)

islower

() -> bool

Returns `True` if all cased characters are lowercase and there is at least one, otherwise `False`.

[Navigate to method\_str\_isspace](#method_str_isspace)

isspace

() -> bool

Returns `True` if the string contains only whitespace and is not empty, otherwise `False`.

[Navigate to method\_str\_isupper](#method_str_isupper)

isupper

() -> bool

Returns `True` if all cased characters are uppercase and there is at least one, otherwise `False`.

[Navigate to method\_str\_join](#method_str_join)

join

(l) -> str

Returns a string that joins the elements of the list, using the string as a separator.

**parameters info**

l

list\[str]

required

List of strings to join.

[Navigate to method\_str\_ljust](#method_str_ljust)

ljust

(length, character) -> str

Left justifies the string within the specified width, padding with the fill character. Returns the original string if width is less than or equal to its length.

**parameters info**

length

int

required

Length of the result string.

character

str

default:
" "

Fill character.

[Navigate to method\_str\_lower](#method_str_lower)

lower

() -> str

Returns a copy of the string with all cased characters in lowercase.

[Navigate to method\_str\_lstrip](#method_str_lstrip)

lstrip

(symbols) -> str

Returns a copy of the string with leading characters removed.

**parameters info**

symbols

str

default:
" "

Characters to remove.

[Navigate to method\_str\_partition](#method_str_partition)

partition

(s) -> list\[str]

Splits the string at the first occurrence of sep and returns a list with the parts before, the separator, and after.

**parameters info**

s

str

required

String separator value.

[Navigate to method\_str\_replace](#method_str_replace)

replace

(oldvalue, newvalue, count) -> str

Returns a copy of the string with all occurrences of old replaced by new, or the first count occurrences if specified.

**parameters info**

oldvalue

str

required

Old value to search.

newvalue

str

required

New value to replace with.

count

int

default:
-1

How many occurrences to replace.

[Navigate to method\_str\_rfind](#method_str_rfind)

rfind

(value, start, end) -> int

Returns the highest index of sub within \[start, end], or -1 if not found.

**parameters info**

value

str

required

Value to search for.

start

int

required

Start index for searching.

end

int

required

End index for searching.

[Navigate to method\_str\_rindex](#method_str_rindex)

rindex

(value, start, end) -> int

Returns the highest index of sub within \[start, end], raising an error if not found.

**parameters info**

value

str

required

Value to search for.

start

int

required

Start index for searching.

end

int

required

End index for searching.

[Navigate to method\_str\_rjust](#method_str_rjust)

rjust

(length, character) -> str

Right justifies the string within the specified width, padding with the fill character. Returns the original string if width is less than or equal to its length.

**parameters info**

length

int

required

Length of the result string.

character

str

default:
" "

Fill character.

[Navigate to method\_str\_rpartition](#method_str_rpartition)

rpartition

(s) -> list\[str]

Splits the string at the last occurrence of sep and returns a list with the parts before, the separator, and after.

**parameters info**

s

str

required

String separator value.

[Navigate to method\_str\_rsplit](#method_str_rsplit)

rsplit

(separator, maxsplit) -> list\[str]

Splits the string into words using sep as the delimiter, with an optional maxsplit from the right.

**parameters info**

separator

str

default:
" "

String separator value.

maxsplit

int

default:
-1

Number of splits.

[Navigate to method\_str\_rstrip](#method_str_rstrip)

rstrip

(symbols) -> str

Returns a copy of the string with trailing characters removed.

**parameters info**

symbols

str

default:
" "

Characters to remove.

[Navigate to method\_str\_split](#method_str_split)

split

(separator, maxsplit) -> list\[str]

Splits the string into words using sep as the delimiter, with at most maxsplit splits, resulting in up to maxsplit+1 elements.

**parameters info**

separator

str

default:
" "

String separator value.

maxsplit

int

default:
-1

Number of splits.

[Navigate to method\_str\_startswith](#method_str_startswith)

startswith

(value, start, end) -> bool

Returns `True` if string starts with the prefix, otherwise `False`.

**parameters info**

value

str

required

Value to check if the beginning of the string equals.

start

int

required

Start index to check the beginning of the string.

end

int

required

End index to check the beginning of the string.

[Navigate to method\_str\_strip](#method_str_strip)

strip

(symbols) -> str

Returns a string with the leading and trailing characters removed.

**parameters info**

symbols

str

default:
" "

Characters to remove.

[Navigate to method\_str\_swapcase](#method_str_swapcase)

swapcase

() -> str

Returns a copy of the string with case swapped.

[Navigate to method\_str\_upper](#method_str_upper)

upper

() -> str

Returns a copy of the string with all cased characters in uppercase.

```py Example theme={null}
# examples of slices extraction:
a = '01234567'
b = a[2:5]  # `b` is '234'
c = a[:5]  # `c` is '01234'
d = a[2:]  # `d` is '234567'
e = a[:]  # `e` is a copy of `a`
f = a[1:7:2]  # `f` is '135'
g = a[5:2:-1]  # `g` is '543'
h = a[5::-1]  # `h` is '543210'
i = a[::-1]  # `i` is '76543210'
```

***

### `tuple[...]`

*type*

Built-in Indie type (similar to Python's).

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.