⤳ Python’s “TypeError: not all arguments converted during string formatting” error occurs for the following reasons: Here’s what the error looks like: When you’re formatting a string As you probably know, Python supports various ways of formatting strings (a.k.a string interpolation): 1. Old string formatting with ...
⤳ The Python error “TabError: inconsistent use of tabs and spaces in indentation” occurs when you mix tabs and spaces to indent lines in a code block. Here’s what the error message looks like: Sometimes the lines look perfectly aligned, but you still get the error. ...
⤳ The “TypeError: unhashable type: ‘dict'” error occurs if you use a dictionary where a hashable object is expected. Whether you’re learning to code, or you’re already a Pythonista, you might encounter this error if: The error looks like this: As you can see, the error message is ...
⤳ Sometimes you need to reverse a range in Python to iterate over a list of items in reverse order. This quick guide explores two popular methods of reversing ranges (or any iterator) in Python. Before we start, let’s quickly review Python’s range() function. A range ...
⤳ The Python error TypeError: missing 1 required positional argument: ‘self’ usually occurs if you call a method directly on a class – rather than an instance of that class. Here’s what the error looks like: When you call a method on a Python object, a ...
⤳ The Python error “IndentationError: unindent does not match any outer indentation level” occurs when the indentation of a line doesn’t match up with the expected indentation level of the current code block. Here’s what the error looks like: In the above error message, Python complains ...
⤳ The Python error “AttributeError: module ‘DateTime’ has no attribute ‘strptime'” occurs when you call the strptime() method on Python’s datetime module – rather than the datetime class inside it. Here’s what it looks like: If you get the above error, your code probably looks similar ...
⤳ If you’re getting the “AttributeError: ‘str’ object has no attribute ‘decode’ error, you’re probably calling decode() on a string object (str) in Python 3. Here’s what the error message looks like in the Python shell: Python 3 stores a string as a sequence of Unicode ...