Reading input (stdin)

Read what you type in the IDE's Input tab with input() or sys.stdin.

Runs in Zerethon IDE · Python 3.12 Official Python documentation ↗

A run cannot ask questions while it runs. Type the program's input in the Input tab before you press Run; input() then reads it one line at a time.

main.py
name = input()
a, b = map(int, input().split())
print(f"Hello, {name}! {a} + {b} = {a + b}")

Input (stdin)

Ada
3 4

Output

Hello, Ada! 3 + 4 = 7
main.py
import sys

numbers = [int(line) for line in sys.stdin if line.strip()]
print("total:", sum(numbers))

Input (stdin)

5
10
15

Output

total: 30
Reading every line of stdin until it ends.

Watch out: input() with nothing left to read raises EOFError: EOF when reading a line. Add the input in the Input tab, one value per line.

Related topics

Official references