Home > OS >  Execute two line Python script in Intellij Idea Python Console
Execute two line Python script in Intellij Idea Python Console

Time:06-11

In Intellij Idea, there is Python Console and it works fine with one-line commands.

I tried to enter a two liner by pressing Shift Enter at the end of the first line which is a common shortcut in chats, for example, and added a second line. Now, the console looks like this and I don't know how to execute the statements I entered:

>>>  for item in l:
...      print(item)

When I press Enter or Shift Enter it just adds another line:

>>>  for item in l:
...      print(item)
...

CodePudding user response:

Press Enter again please
Imagine if you press Enter once to execute, how to add other statements

>>> a = [1, 2, 3, 4, 5]
>>> for i in a:
...     print(i)
... 
1
2
3
4
5
>>> 

CodePudding user response:

I figured this out: you just need to press Enter twice after you finished with your input. Pressing Enter after an empty line will execute everything you wrote above:

>>> for item in l:
...     print(item)
...     
sarah
roark
sasha
45
ffffuuu
5.6

The list values are output after the second ...

  • Related