- 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

4th Jun 2020, 6:27 PM
Nina Intercrossed
Nina Intercrossed - avatar
11 Answers
+ 1
Thank you Olivia and Kiibo, I tried what you suggested but it still didn't work :(
4th Jun 2020, 9:53 PM
Nina Intercrossed
Nina Intercrossed - avatar
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)
4th Jun 2020, 6:32 PM
Nina Intercrossed
Nina Intercrossed - avatar
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
4th Jun 2020, 6:32 PM
Olivia
Olivia - avatar
0
Write exactly this: x=7 x+=2 print(x)
5th Jun 2020, 6:27 AM
Olivia
Olivia - avatar
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 :/
5th Jun 2020, 10:00 AM
Nina Intercrossed
Nina Intercrossed - avatar
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
5th Jun 2020, 11:55 AM
Olivia
Olivia - avatar
0
Thank you for your help :)
5th Jun 2020, 1:36 PM
Nina Intercrossed
Nina Intercrossed - avatar