0

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)
...
1
  • 2
    press Enter one more time. Commented Jun 9, 2022 at 8:45

2 Answers 2

1

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
>>> 

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I have sorted this out myself but accepting this answer as correct ;)
0

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 ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.