I am getting an indentation error, but my code is indented properly. If I take out the if statement, the code will run fine. Here is the relevant snippet:
80 try:
81 votes_a = breakdown[0]['count']
82
83 if breakdown[0]['pick'] != m.home:
84 votes_b = votes_a
85 except IndexError:
86 votes_a = 0.0
If I remove lines 83 and 84 the code will work. Is it not possible/advisable to have control statements within try/except blocks of python code?
cheers
Update:
The indentation error was not in the line that django told me, it was the line above. And, yes, there was one tab thrown in there instead of a space. Thanks.
Of course it’s possible. If you get indentation errors, but indentation looks good visually, there’s a good chance you’ve mixed tabs with spaces. It’s best to not use tabs at all. You can run Python with
-ttto detect inconsistent tab usage.