Python Input Function

basic of python,

Sourabh Somani Sourabh Somani Follow Apr 10, 2018 · 1 min read
Share this

Introduction

In this tutorial, we will learn input function of the python function

Python input() function

Python input function is used to take input from the console. The input() method reads the line from sys.stdin and returns it with the trailing newline stripped. It raises EOFError if the input is terminated prematurely.

Syntax

Syntax of the input() method is as follows

 
input([prompt])

prompt

In the syntax you can see, python input function takes prompt argument. This argument is option argument.

Example

 
name = input("What is your name? \n")
print("Hello"+name)
Join Newsletter
Get the latest news right in your inbox. We never spam!
Sourabh Somani
Written by Sourabh Somani Follow
Sourabh Somani is a Full-Stack Engineer with several years of hands-on experience. He has been awarded 4-times Microsoft MVP award consecutively and C# Corner MVP Award 6-times. Most of the time you will find him helping people on C# Corner and StackOverflow on JavaScript, .NET and Python. He is a frequent contributor to open source software development via forums, articles, and blogs. He regularly speaks at user groups and developer conferences. His core technology interests are JavaScript, Python and .NET.