---
title: "int"
space: "Student Handbook"
url: "https://portal.cs17.org/student-handbook/python-manual/built-in-functions/int"
updated: "2026-10-05"
---

Converts a value to a whole number.

## Synopsis

```python
int(value)
```

## Description

Use `int` on what `input` returns to get a number you can do maths with.

On a float, `int` drops everything after the decimal point. This is called **truncation**: `int(3.9)` is `3`, and `int(-3.9)` is `-3`.

## Parameters

| Name | Meaning |
| --- | --- |
| `value` | A string of digits, such as `"42"`, or a float. |

## Return value

An `int`.

## Example

```python
age = int(input("Age: "))
print(age + 1)
print(int(3.9))
print(int(-3.9))
```

It prints:

```text
Age: 14
15
3
-3
```

## Common mistake

```python
n = int(input("Number: "))
```

Python stops with:

```text
Number: cat
ValueError: invalid literal for int() with base 10: 'cat'
```

The string must hold only a whole number. `"cat"` fails, and so does `"3.5"`. To accept decimals, use `float`.

## See also

[float](/student-handbook/python-manual/built-in-functions/float), [input](/student-handbook/python-manual/built-in-functions/input), [round](/student-handbook/python-manual/built-in-functions/round), [math.floor](/student-handbook/python-manual/math/floor)

[int in the Python documentation](https://docs.python.org/3/library/functions.html#int)
