How to take string input in Python | Example code

You can take input in Python by using the raw_input() or the input() function command. The input() function reads the input and assigns whatever datatype it thinks best suits the input.


prompt:- A String, representing a default message before the input.

Note: raw_input() function has been discontinued in Python 3 and is only available in Python 2.

Example take string input in Python

Simple example code takes input from the user and returns (print) it.

name = input("Enter your name: ")



How to take string input in Python

Do comment if you have any doubts and suggestions on this Python input program.

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.