Elif Giving Syntax Error Python?
Solution 1:
As I mentioned in a comment, I had an error like this once that was due to a extra tab character that just happened to be right at a position where it did nothing visible.
If your editor will let you view invisible characters like tabs and newlines, you may be able to actually see if that the case. My editor also has an option to convert tabs to spaces which would fix such a problem. If all else fails, just delete all the whitespace at the beginning of the line and then carefully do it over and then see if the error still occurs.
Recently I ran across a really good answer to a similar question How can I add a print statement to this code without getting an indentation error.
Solution 2:
The if at the middle part, as shown below:
"if 'artist' in path and not 'extraartists' in path and not 'track' in path: outfile.write( 'artist = ' + elem.text.encode('utf-8') + '\n' )"
Should be closed with an else before you go back into "elif elem.tag == 'title':"
My advice is to create another if function instead of an if inside an if. It would be less complicated.
Post a Comment for "Elif Giving Syntax Error Python?"