I have created a MWE:
x = True
if x:
print('111111')
y = 1
When running in python interactive mode, I get
>>> x = True
>>> if x:
... print('111111')
... y = 1
File "<stdin>", line 3
y = 1
^
SyntaxError: invalid syntax
>>>
The code looks very correct. If I add them line by line, they will be fine but now when copying them all together.
What is wrong?
>Solution :
The interpreter is saying that the indentation of the second statement y=1 was unexpected.You should have entered a blank line to end the first statement (i.e., "if") , before you start writing the next statements(i.e y=1).
>>> x=True
>>> if x:
... print('1111')
...
1111
>>> y=1