I am starting with Python and have a problem with the .input() method:
The code is simple:
print("Please enter something")
message = input("Test Input: ")
print(message)
As far as I know, .input is supposed to return a string, but when I try to code in the terminal this does not happen.
When I execute the code the following happens: If I just enter a string (without quotation marks) I get the error message
Please enter something
Test Input: Input_test
Traceback (most recent call last):
File "message.py", line 2, in <module>
message = input("Test Input: ")
File "<string>", line 1, in <module>
NameError: name 'Input_test' is not defined
However, when I enter a string with quotation marks, or when I enter a integer, everything works fine:
Please enter something
Test Input: 12
12
Please enter something
Test Input: "Test_input"
Test_input
This behaviour is confusing as I because resources are saying that .input is already returning a string, so why is the code only working when I explicitly enter a string or an integer? Especially the error message (that the input is not being defined) is a mystery to me.