Python Forum
IndentationError: unexpected indent
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndentationError: unexpected indent
#7
I would probably not call a variable in_something for that reason alone
Error:
File "tester.py", line 7 if item in_stock: ^ SyntaxError: invalid syntax
Although you are allowed to name a variable anything in python, we prefer to restrict certain ones... such as no built-in's or single char names , CamelCase class names, capped GLOBALS, etc. I would probably add to the list things like in_var as when you read a if header, it suppose to be English readable
Quote:if item in in_stock:
and a double in is not readable as well as obviously causing syntax bugs

Im not sure why you got an indentation error. I would also never mix tabs and spaces. Convert all copied code to 4 spaces as that is the norm.

Also use the format instead of concatenation
https://python-forum.io/Thread-Basic-str...xpressions
Recommended Tutorials:
Reply


Messages In This Thread
RE: IndentationError: unexpected indent - by metulburr - Oct-31-2017, 12:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help with "IndentationError: expected an indented block" hequ 3 6,550 Mar-02-2020, 06:26 AM
Last Post: Pranav
  IndentationError: expected an indented block python1980 3 7,734 Dec-03-2017, 10:00 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020