Python Forum

Full Version: Input function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am new user for python and im currently following a PDF for samples. I'm stuck where the function ( input is not working ).

code is
message = input("Tell me something, and I will repeat it back to you: ")
print(message)
please help.
Are you running this as a script, or typing it directly into the python interpreter? It works fine when run as a script.

If you are typing in the python interpreter you need to enter the message after the input statement and before the print statement. Like this.
Output:
> python Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> message = input("Tell me something, and I will repeat it back to you: ") Tell me something, and I will repeat it back to you: this is the message >>> print(message) this is the message >>>