• Python indention error
    3 replies, posted
I've encountered an error which just doesn't make sense. [code] def getinput(): raw_input(" - ", prompt) if prompt == "!start": #startcode elif prompt == "!quit": #quitcode elif prompt[1:] != "!": #check that first char isn't a ! #checking the prompt else: #shouldn't really be here... return -1 [/code] On the first elif, it gives the error "expected an indented block". However, it is properly indented as far as I can understand, like all other indentions, it is indented using tab. Any ideas? :/
If you are doing nothing, you need the pass-keyword, which does nothing but is a place-holder for places, where python expects something to be done.
You can't have blank if statements. Put pass at the end. So it'll say: [code] if prompt == "!start": #startcode pass elif prompt == "!quit": #quitcode pass elif prompt[1:] != "!": #check that first char isn't a ! #checking the prompt pass [/code] You can take the pass out when you add real code.
Ohhh, thanks a lot! I noticed that it probably had something to do with the other elses, but the only idea was that it had something to do with the comments. >_< Thanks again btw.
Sorry, you need to Log In to post a reply to this thread.