When Python is first installed, the default setting executes users’ code input line-by-line. But sometimes I need to write programs that execute multiple lines at once. Is there a setting in Python where I can change the code execution to one block at once?
>>> if (n/2) * 2 == n:;
print 'Even';
else: print 'Odd'
Error:
SyntaxError: invalid syntax
When I tried to run the above code, I got an invalid syntax error on the else.
Your indentation is wrong. Try this:
Also you might want to write it on four lines:
Or even just one line: