So your error for line 23 of your code IndentionError: unexpected indent should indicate to you that your return statement in line 23 is spaced improperly… try changing that
Probably mixed tabs and spaces, yeah
@ionatan is almost certainly correct.
A key question to consider: How does he know that the problem is mixed tabs and spaces?
That’s such a tricky question, I can barely answer that myself
But in short, because tabs mean different things depending on where tabstops are considered to exist (and may therefore look ok in one editor but not in another, or in this case, to python). Yes, this makes them a horrible idea and just cause for holy war. Spaces.
Visually, the indentation in the screen capture looks correct. However, the interpreter reports an
IndentionError. That suggests that it would be a problem of mixed kinds of whitespace.
If the code were posted as text, we could select the whitespace as we observe how the highlighting proceeds to confirm that.
Ruby’s source code isn’t funny
Tabs are used as TWO indentation levels, and for one level they use space… Except when they just don’t care and it’s all spaces or a tab in the middle
Yeah, Python is unusual among languages in that it depends upon indentation to define the block structure of the code. Personally, I like it that way, but wonder how others feel about it.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.