Sometimes python 2.5.4. does not automatically indent, so I indent 4 spaces and I always get an error. I am stuck on the third lecture! How do I fix this?
for example after a while statement and two indented lines below it, if will not go back to the margin.
What editor are you using?
I think some editors require consistency between using tabs and spaces..You can't combine both in the same script.. I use Sublime Text, and no issues with the Python compiler.
If you are using vim, put this into your .vimrc and everything will work flawlessly: " 1 tab = 4 spaces, auto indenting filetype indent plugin on set tabstop=8 set expandtab set shiftwidth=4 set softtabstop=4
Although visually the same, four spaces are not the same as one tab. Blocks of code (the indented lines) have to use the same indentation throughout that block. IDLE has a problem with this, so it's not one that I use.
I do not understand why the professor of the course can use python Idle with no problems, and I can't!
Are you typing a colon after ifs and loops? if <condition>: \(\leftarrow\) it is that : that triggers the indent.
Join our real-time social learning platform and learn together with your friends!