How to use input function in Python | Example code

Using the input() function is easy just use a variable to assign the input function. This variable will have a user input value.

This function is used when you want to interact with users.

x = input()

Example to use input function in Python

Simple example code uses the prompt parameter to write a message before the input() function.

print('Enter your name: ')
x = input()

print('Hello, ' + x)

Output:

How to use input function in Python

Do comment if you have any doubts and suggestions on this Python function topic.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.