Jan-17-2022, 07:32 PM
I see no reason why you would ever use input() in interactive mode. I guess it kind of works but it is really awkward.
If I do this in interactive mode it appears to work (awkwardly).
If I do this in interactive mode it appears to work (awkwardly).
Output:>>> x = input("A")
Ahi
>>> print(x)
hi
I can also do this which is a bit less awkward.Output:>>> x = input("A"); print(x)
Ahi
hi
It would make a lot more sense to write:Output:>>> x = "hi"
>>> print(x)
hi
But you are right that you cannot paste two lines into an interactive session and have it work.Output:>>> x = input("A")
Aprint(x)
>>> hi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'hi' is not defined
So what is the problem?