Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python in terminal: how to signify end of for loop?

Say I want to print 0 through 9.

I type in for i in range(10): print(i), press enter, and terminal shows ..., waiting for further statements.

So I have to press enter again to have the numbers printed.

>>> for i in range(10): print(i)
...

How can I have the number printed without having to press enter twice?

like image 678
kgf3JfUtW Avatar asked Mar 08 '17 20:03

kgf3JfUtW


2 Answers

Just type the two returns and move on. But since you ask, this only needs one Enter:

exec("for i in range(10): print(i)")
like image 98
alexis Avatar answered Sep 23 '22 15:09

alexis


"alt+enter" I was working in ipython and facing the same problem as yours. upon trying various combinations from keyboard, this one finally worked

like image 41
Paarmita Avatar answered Sep 22 '22 15:09

Paarmita