Python indentation errors.
[deleted]
I am making a game in python where you select to go north south east or west and currently it says I have an indent error on the first if statement even though it is the same indentation as the other ones in the function.
Here is the link. Thank you guys for the replies, I fixed it.
https://repl.it/@MarcoGonterman/Adventure-Time
DanielSchumache
There were some indention errors. I fixed it:
https://repl.it/@DanielSchumache/Adventure-Time
kirandeepswan
@DanielSchumache will you be able to help me fix my indentation errors pls I need to turn in a project that is worth 200 points
MarquizeWhite
@kirandeepswan 200 points MINES FOR MY FRESHMAN FINALES project worth like all my grade
There is a hidden indentation issue to do with the "direction = input(..... " line of code. Your "ifs" are too far indented as well. What you need to do is highlight all the code in the movement function then hold down the shift key and press the tab key. This will unindent the code by one tab. Repeat this until "direction = input(... " and the "if" blocks of code are touching the left hand edge. The code should still be highlighted (as long as you have not clicked away from it). Now press just the tab key once. The code should now be correctly indented.
Your code could be more efficient. After the first "if" use "elif"s instead of the repeated "if"s, apart from the last "if" which could be an "else" as it is the last possible choice.
There are one or two other things you could do to improve your code. For instance, how can the user break out of the movement function as it is always called?