[Python] elif & else
Show an example of code that gives that problem. Make sure to use [code] or [source] tags to ensure that the spacing shows up properly.
Did you put colons after them?
ie
ie
if blah: do_stuff()elif that: do_other_stuff()else: do_nothing()
Quote:Original post by X Jado X>>> if 9 == 9: do_stuff() elif that: SyntaxError: invalid syntax
Elif is higlighted.
The "elif" needs to be indented to the same level as the "if".
Quote:Original post by bakery2k1Quote:Original post by X Jado X>>> if 9 == 9: do_stuff() elif that: SyntaxError: invalid syntax
Elif is higlighted.
The "elif" needs to be indented to the same level as the "if".
Yeah that's one of the things that first aggravated me when I first learned Python never mind not using elseif like 99% of the other languages!
Since whitespace matters also unlike 99% of other languages a good Python editor is essential since I used the one that came with Python and it never alerted me to silly mistakes like this.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement