I want to write the following two lines on the console:
x = 3
print x**5
But when I type x = 3
, I press enter, it then executes the assignment. How to get it to execute only after typing the second line?
I want to write the following two lines on the console:
x = 3
print x**5
But when I type x = 3
, I press enter, it then executes the assignment. How to get it to execute only after typing the second line?
End lines with ;\
:
>>> x=3;\
... print x**5
243
>>>
Use the Ctrl-J key sequence instead of the Enter key to get a plain newline plus indentation without having IDLE start interpreting your code.
You can find other key sequences that make IDLE easier to use for this type of learning under the Options->Configure
IDLE menu.
End lines with ;\
:
>>> x=3;\
... print x**5
243
>>>
To code group of statements, ;\
will work
list1=[1,2,3]
list2=[4,5,6]
print list1;\
print list2
Will print both the lists
Where as, for Indentation
statement, you need :\
for i in list1:\
print i
//double enter
Will show all the elements in the list
x = 3; print x ** 5
should help, but it doesnt matter that its executed the way it is in IDLE.
Just open a new file: File > New window. You can run it by clicking run > run module.
the "\"
line at the end of the line works for me. in windows 10 cmd.
Edit: I've also noticed that you have to be consistent with its use, other wise you still get syntax error
Go into editor mode with the F2 key. Depending on your terminal config this will put you in vim or nano. You can edit a snippet of code and then exit editor mode to get back to the ipython cli with your code and any newlines.
© 2022 - 2024 — McMap. All rights reserved.