While the indentation errors are obvious in the StackOverflow page, they may not be in your editor. You have a mix of different indentation types here, 1, 4 and 8 spaces. You should always use four spaces for indentation, as per PEP8. You should also avoid mixing tabs and spaces.
I also recommend that you try to run your script using the ‘-tt
‘ command-line option to determine when you accidentally mix tabs and spaces. Of course any decent editor will be able to highlight tabs versus spaces (such as Vim’s 'list'
option).
Related Posts:
- What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
- IndentationError: unindent does not match any outer indentation level
- What to do with “Unexpected indent” in python?
- Putting a simple if-then-else statement on one line [duplicate]
- How can I do a line break (line continuation)?
- syntaxerror: “unexpected character after line continuation character in python” math
- `from … import` vs `import .` [duplicate]
- What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
- Python: SyntaxError: keyword can’t be an expression
- How to normalize a 2-dimensional numpy array in python less verbose?
- SyntaxError invalid token
- What is the difference between ‘/’ and ‘//’ when used for division?
- Printing variables in Python 3.4
- Error “‘type’ object has no attribute ‘__getitem__'” when iterating over list[“a”,”b”,”c”]
- Tab Error in Python
- Automatic indentation for Python in Notepad++
- IndentationError: unexpected unindent WHY?
- Inline for loop
- Python def marked as invalid syntax
- Indent Expected?
- bash: syntax error near unexpected token `(‘ – Python
- How to fix IndexError: invalid index to scalar variable
- How to write inline if statement for print?
- Could not install packages due to a “Environment error :[error 13]: permission denied : ‘usr/local/bin/f2py'”
- How does numpy.newaxis work and when to use it?
- How to move a file in Python?
- Round a floating-point number down to the nearest integer?
- beyond top level package error in relative import
- How do you append to a file?
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- Jupyter Notebook not saving: ‘_xsrf’ argument missing from post
- What does it mean to have an index to scalar variable error? python
- Could not install packages due to an EnvironmentError:
- What does “e” in “1e-5” in Python language mean and what is the name of this notation?
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- Does Python have “private” variables in classes?
- Rename Pandas DataFrame Index
- How to upgrade pip3?
- Is module __file__ attribute absolute or relative?
- How do I convert a list of ascii values to a string in python?
- How can I compare two lists in python and return matches
- Convert DataFrame column type from string to datetime, dd/mm/yyyy format
- How can I remove a trailing newline?
- Is there a list of line styles in matplotlib?
- Import urllib.request, ImportError: No module named request
- Python list directory, subdirectory, and files
- Parsing boolean values with argparse
- Running Jupyter via command line on Windows
- Using Pip to install packages to Anaconda Environment
- Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn’t work
- How to create new folder?
- Python Sets vs Lists
- How do I resize an image using PIL and maintain its aspect ratio?
- Display image as grayscale using matplotlib
- How to update SQLAlchemy row entry?
- django MultiValueDictKeyError error, how do I deal with it
- Python, print all floats to 2 decimal places in output
- RuntimeWarning: divide by zero encountered in log
- clang error: unknown argument: ‘-mno-fused-madd’ (python package installation failure)
- Deleting DataFrame row in Pandas based on column value
- Timeout on a function call
- python is not recognized windows 10
- Haversine Formula in Python (Bearing and Distance between two GPS points)
- How to join on multiple columns in Pyspark?
- How can I login to a website with Python?
- How do I correctly use the mod operator in MIPS?
- Does Numpy automatically detect and use GPU?
- Properly formatted multiplication table
- How can I check whether a numpy array is empty or not?
- What is a ‘NoneType’ object?
- Class constants in python
- How do I print the key-value pairs of a dictionary in python
- urllib2 HTTP Error 400: Bad Request
- ImportError: No module named ‘xlrd’
- How to repeat a string with spaces?
- NameError: name ‘requests’ is not defined
- Seaborn Lineplot Module Object Has No Attribute ‘Lineplot’
- kernel keeps dying in jupyter notebook
- Moving Average Pandas
- Plotting of 1-dimensional Gaussian distribution function
- How to fix error “ERROR: Command errored out with exit status 1: python.” when trying to install django-heroku using pip
- Is it possible to use ‘else’ in a list comprehension?
- How to randomly get 0 or 1 every time?
- jinja2.exceptions.TemplateNotFound error [duplicate]
- Loading and parsing a JSON file with multiple JSON objects
- How to get ° character in a string in python?
- What is the difference between an expression and a statement in Python?
- How to handle a Button click event
- Numpy Resize/Rescale Image
- numpy array concatenation error: 0-d arrays can’t be concatenated
- Difference between modes a, a+, w, w+, and r+ in built-in open function?
- How can I color part of Slack incoming-webhook messages?
- How to import or include data structures (e.g. a dict) into a Python file from a separate file
- In python, how can I print lines that do NOT contain a certain string, rather than print lines which DO contain a certain string:
- input() error – NameError: name ‘…’ is not defined
- A very basic setting issue about spyder and anaconda for python
- ImportError: No module named BeautifulSoup
- How to install numpy to Python 3.5?
- How do you switch between python 2 and 3, and vice versa?
- Iterating over dictionary items(), values(), keys() in Python 3