Is there a way to write code in a way that when I press enter, the code does not run? I'm also wondering why I can not write two if statements. I get a syntax error when I try. Here is the code. >>> x = 15 >>> if (x/2)*2 == x: print 'Even' else: print 'Odd' if x == 15: print 'FIFTEEN' else: print 'NOT FIFTEEN' SyntaxError: invalid syntax >>>
The SyntaxError highlights the second if in red.
ctrl-c will stop execution in the idle shell - you might have to hold it down if it is in a dee recursion. this will preserve any variables. ctrl-F6 will restart the idle shell Idle: select New Window from the File menu - write your code in there and F5 to run it
Thank you for your response. I typed the code into a "New Window" and ran the module and it worked. What is the difference between the "New Window" and the IDLE Shell?
the "new window" lets you create 'modules' with multiple statements/expressions/code blocks. apparently the idle shell only lets you run/evaluate a single compound statement - it wants to evaluate it immediately
I really appreciate your help. Thanks again.
the idle shell is a great way to test things out (prototyping) when you are trying to figure out how to do something
Join our real-time social learning platform and learn together with your friends!