Interview Question

What is input() function?

input() reads a line and returns text.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

input() reads one line from standard input and returns it as a string. • A prompt string can be written before reading. • The trailing newline is removed. • Convert and validate the returned string when another type is required.

💡 Simple Example

name = input('Name: ') print(f'Hello, {name}')

Output

Depends on user input

⚡ Quick Revision

input() reads a line and returns text.