Python Program to accept a string value

How to accept and print a string in python?

Python programming language is very optimistic for a programmer. In the previous program, to print hello world using python language, it is elementary to accept a string or any value from the user. The basic concept is to read a string entered by the user and store it in a variable in some memory location.

This program is for beginner-level python programmers; it is effortless to understand this bit of python program code. We use a variable named it as str and using that variable, we accept a string data type in python from the user, using an input function. Like C, we do not need to include any header files for using the input function. In python, we accept the string, and we print it using the print function.


STEP 1: Accept a string from the user and save that to a variable.

STEP 2: Display the string using the print method.

Python Source Code

                                          str = input("Enter any string: ")


Enter any string: hello python
hello python