Making a Purchase(Indent Error)


#1


#2

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 :smiley:


#3

Probably mixed tabs and spaces, yeah


#4

@ionatan is almost certainly correct.

A key question to consider: How does he know that the problem is mixed tabs and spaces?


#5

That’s such a tricky question, I can barely answer that myself :confused:

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.


#6

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.


#7

Ruby’s source code isn’t funny

https://github.com/ruby/ruby/blob/trunk/math.c

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


#8

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.


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.