all Python 3Input & outputfunction
input()
input
Built-in function that reads a line from the keyboard. It prints an optional prompt and returns the line entered, without the trailing newline.
Syntax
input([prompt]) -> str
input() always hands back a string — "42" is still text, and int() on empty or non-numeric input raises ValueError. When the stream runs out (a file or pipe in an autograder) it raises EOFError rather than returning an empty string, so bound the read loop by a known count or catch EOFError. The prompt goes to the very same stdout as your answer, which is why graded solutions call input() with no argument.
Examples
# name = input("Введите имя: ") # пользователь вводит строку
# age = int(input("Возраст: ")) # → преобразование в int
# price = float(input("Цена: ")) # → преобразование в float
# Проверка: s = input(); x = int(s) if s.isdigit() else 0 # input() один раз
# line1 = input("Строка 1: "); line2 = input("Строка 2: ")
# s = input().strip() # ввели " hello " → "hello" (strip чистит сам ввод)
# Симуляция ввода без клавиатуры:
import io, sys
sys.stdin = io.StringIO('Alice\n')
print(input()) # → Alice
sys.stdin = sys.__stdin__
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy