Skip to content
Sign upLog in
← Back to Community

Python indentation errors.

Profile icon
[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

Voters
Profile icon
preranalokhande
Profile icon
Jorge-Francisc2
Profile icon
MansiKhandelwa1
Profile icon
fireboltR
Profile icon
NischayRawat
Profile icon
OlivierT
Profile icon
YashrajMogal
Profile icon
Carlos_EmilioE1
Profile icon
DanielSchumache
Profile icon
SamWhite3
Comments
hotnewtop
Profile icon
[deleted]

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?

Profile icon
DanielSchumache

There were some indention errors. I fixed it:
https://repl.it/@DanielSchumache/Adventure-Time

Profile icon
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

Profile icon
MarquizeWhite

@kirandeepswan
200 points MINES FOR MY FRESHMAN FINALES project worth like all my grade

Profile icon
migoyo

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. brand design

Profile icon
gregory54

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.먹튀검증사이트

Profile icon
gregory54

Thanks for sharing us. อนิเมะ

Profile icon
migoyo

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. เว็บ พนัน อันดับ 1

Profile icon
fireboltR

'