---
title: The input() Function in Python
source: https://app.sythra.ai/learn/python/python-input-function
topic: Python
updated: 2026-08-12
publisher: Sythra (https://app.sythra.ai)
---

# The input() Function in Python

Python's input() function pauses a program, waits for the user to type something, and returns it as a string — even if it looks like a number. Convert it with int() or float() before doing math.

_Source: [https://app.sythra.ai/learn/python/python-input-function](https://app.sythra.ai/learn/python/python-input-function) — free to read on Sythra._

## Key points

- input() pauses the program and waits for the user to type
- input('prompt') shows a prompt before waiting
- input() always returns a string, never a number
- Convert with int(input(...)) or float(input(...)) to do math
- Unexpected input (like letters for a number) raises a ValueError
- input() is the first bridge between your program and a real user

Every program you have written so far is one-way — it outputs things but never asks the user for anything. Python's `input()` function changes that: it **pauses** the program, waits for the user to type something, then hands you back exactly what they typed.

This page covers how `input()` works, why everything it returns is a **string** even when the user types a number, and the classic bug that trips beginners up. Pair it with [Data Types in Python](/learn/python/data-types) for why the string-vs-number distinction matters here.

## What you will learn

By the end you can:

- Use `input()` to pause a program and read what the user types
- Add a prompt so the user knows what to type
- Explain why `input()` always returns a **string**
- Convert input to a number with `int()` or `float()` when you need to do math
- Recognize the `ValueError` that happens with unexpected input

## Reading a value from the user

Call `input()` with no arguments and Python waits silently until the user types something and presses Enter:

```python
text = input()
# waits, then returns exactly what the user typed
```

Usually you want to tell the user what you are asking for. Pass a string to `input()` and Python shows it as a prompt before waiting:

```python
name = input("What is your name?\n")
# shows the prompt first, then waits
```

The `\n` at the end is a newline character — it moves the cursor to the next line before the user starts typing, which just looks cleaner.

## input() always returns a string

This is the detail that catches almost everyone: no matter what the user types — even if it looks like a number — `input()` hands it back as a **string**. If you want to do maths with it, you have to convert it first.

```python
speed = input("Enter your speed: ")
speed = int(speed)
# converts the string '60' into the number 60
```

Or more concisely, on one line — convert right where you read it:

```python
speed = int(input("Enter your speed: "))
```

> **Why this trips people up:** 

## When conversion fails

If the user types something unexpected — letters when you asked for a number — `int()` raises a `ValueError`:

```python
speed = int(input("Enter your speed: "))
# user types "fast"
# ValueError: invalid literal for int() with base 10: 'fast'
```

Handling that kind of error properly (so the program does not just crash) belongs to a later topic on exceptions — for now, just know it can happen and why.

## Common mistakes

- Trying to add or subtract straight from `input()` without converting first
- Forgetting the prompt string, leaving users staring at a blank, silent program
- Using `int()` on input that might contain a decimal point (use `float()` instead)
- Assuming `input()` validates anything — it accepts whatever the user types, valid or not

## Why this matters

`input()` is the first real bridge between your program and a human. Almost every interactive script — calculators, quizzes, command-line tools — starts here. Getting the string-to-number conversion habit right early saves you from a whole category of "why won't this add up" bugs later.

> **Practice with Sythra:**  [Practice with AI tutor](https://app.sythra.ai/pricing)

## FAQ

### What does the input() function do in Python?

input() pauses program execution, waits for the user to type something and press Enter, then returns exactly what they typed as a string.

### Does input() return a string or a number in Python?

input() always returns a string, even if the user types digits. To use it as a number, convert it explicitly with int() or float().

### How do you convert input() to an integer in Python?

Wrap the call: age = int(input('Enter your age: ')). This reads the string from input() and converts it to an int in one line.

### Why does input() cause a ValueError in Python?

A ValueError happens when you try to convert input() to a number (with int() or float()) but the user typed something that is not a valid number, like letters.

### How do you add a prompt message to input() in Python?

Pass a string as the argument, like input('Enter your name: '). Python displays that text before pausing to wait for the user's response.

## Related

- [Data Types in Python](https://app.sythra.ai/learn/python/data-types) — Why input() returning a string matters for the type you actually need.
- [Types, Values, and Errors in Python](https://app.sythra.ai/learn/python/types-values-errors) — More on how type() and conversions work.
- [Variables in Python](https://app.sythra.ai/learn/python/variables) — Storing what input() gives you back for later use.
- [Interactive Mode vs Script Mode in Python](https://app.sythra.ai/learn/python/interactive-mode-vs-script-mode) — How input() behaves the same way in both modes.
- [Strings in Python](https://app.sythra.ai/learn/python/strings-in-python) — Indexing, slicing, immutability, and string methods.
- [Lists in Python](https://app.sythra.ai/learn/python/lists-in-python) — Mutability, list methods, map/filter/reduce, and the aliasing trap.
- [Type Casting in Python](https://app.sythra.ai/learn/python/type-casting) — Implicit vs explicit conversion between data types.
- [Python course hub](https://app.sythra.ai/learn/python) — All free Python explainers and the path into Agentic practice.

---

Written by Sythra — Learn machine learning by building. Practice this topic with Sythra's AI tutor: https://app.sythra.ai/pricing
