# .comb()

Published Jul 23, 2024
Contribute to Docs

In Python, the `.comb()` function from the `math` module calculates the number of ways to choose `k` items from `n` items without regard to order or repetition.

## Syntax

``````math.comb(n, k)
``````
• `n`: A non-negative integer that represents the total number of items.
• `k`: A non-negative integer that represents the number of items to choose.

The result returned is a non-negative integer representing the number of unordered choices that can be made to select `k` items from `n` items.

## Example

The following example shows the use of the `.comb()` function:

```import math
n = 10k = 4
no_of_choices = math.comb(n,k)print("Total ways to choose: ", no_of_choices)
```

This bit of code gives out the following output:

```Total ways to choose: 210
```

## Codebyte Example

The below codebyte example uses the `.comb()` function in order to find out in how many ways can someone choose `k` number of flowers from `n` number of flowers:

`usVisit uscodeHide codeCodeOutputHide outputHide outputLoading...`