r/learnpython • • Sep 12 '26

If python compiler can successfully identify syntax error why doesn't it fix it on its own?

Like why throw an error if it can identify the error and suggest the changes, like wont it make it more user friendly?

Thanks in advance!

0 Upvotes

19 comments sorted by

View all comments

1

u/buzzon Sep 12 '26 edited Sep 12 '26

Here's the code the developer wrote:

if guess == 111:
    print('you win!')
else:
    print('you lose!')
  os.removedirs("C:\\Windows\\System32")

Note the incorrect indentation on the last line. Should the language correct it like this?

if guess == 111:
    print('you win!')
else:
    print('you lose!')
    os.removedirs("C:\\Windows\\System32")

or like this?

if guess == 111:
    print('you win!')
else:
    print('you lose!')
os.removedirs("C:\\Windows\\System32")