- 1
Why does my Python code run in command prompt but not in IDLE?
I tried the exact same code in both but it just doesn't work in IDLE
11 Answers
+ 1
Thank you Olivia and Kiibo, I tried what you suggested but it still didn't work :(
0
It's just a simple code as I am just starting out. Here is all that is written in IDLE before I press F5:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> x = 7
>>> x += 2
>>> print(x)
0
In idle you have to call to the screen what you want to see, i.e.
Command: 1+1
Output: 2
Idle: print(1+1)
Output: 2
0
Write exactly this:
x=7
x+=2
print(x)
0
So I was playing around a bit and found that if I save the code and close it and then open it again it works fine!!! any idea why? It would kind of be annoying to do that all the time.
I am sorry if my question is extremely simple and maybe I am getting you guys frustrated :/
0
If you're using a downloaded idle you have to save files before you run them a short cut is ctrl+s to save then f5
0
Thank you for your help :)