I searched the first page of Google but couldn't find an answer. This won't happen for int(raw_input()) weirdly enough. But if i type:
a = [raw_input() for i in range(int(raw_input()))]
print(a)
Example input: 5 1 2 3 4 5
The output will be: ['1\n', '2\n', '3\n', '4\n', '5\n']
I know this has something to do with the IDE (I run VSCode) but I have no clue how to fix it. Thank you.
In Python3.x, raw_input()
and input()
are integrated, raw_input()
is removed, only the input()
function is retained, which receives any input, defaults all input to string processing, and returns the string type.
When use Python2.7:
When use Python3.8:
In addition, if you use extensions for debugging other than the python extension in VS Code, please try to disable it to avoid affecting the results.
My environment:
VS Code: 1.52.1 (user setup); OS: Windows_NT x64; VS Code extension: Python; Pylance;
Reference: What's new in Python3.