Why Python reports about different errors for the same reason, the programs with the 1 and 2 lines of code?
I mean:
print(1
gives
Error: unexpected EOF while parsing
but
a = 1+1
print(1
gives
Error: invalid syntax
same problem - but error message is different - reason?
sys.version_info(major=3, minor=2, micro=0, releaselevel='final',serial=0)
When we do something right, a pathway is created. Unfortunately, a pathway is also created when we something wrong. We basically build habits this way, both good and bad. So the reason we keep making the same mistakes is that we slip by default back into existing neural pathways.
Sometimes, it is necessary for us to make mistakes several times, in order for us to fully learn and grow from them. Even if it is the same mistake. Reconcile with the fact that you are human. You will never be perfect and you need to go easy on yourself.
When an employee repeatedly makes the same mistake gives him a chance to correct himself it is known as warning.
In your first case python is 'looking' for its FIRST line/command. The minimum for a program is at least one statement. So it complains about early termination.
So the first error EOF (end of File) means: 'Hey I was expecting at least one command and suddenly the line ended...' 'Are you sure the program is completed?'
The second error the previous was run so the compiler 'knows' that this is a program.
and the error is different but it means:
'Hey I for now you have a error in this position, can you fix your sintaxe'?
I hope my non academic way do not distracted you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With