⤳ 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 “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 parameter ...
⤳ Python’s infamous “IndentationError: unindent does not match any outer indentation level” error 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 ...
⤳ The JavaScript error “Await is only valid in Async functions” occurs when you use an await expression outside an async execution context, like an async function or top-level body of an ES module (top-level await). How to fix it? First of all, we need to determine where ...
⤳ If you need a cross-browser approach to convert a dd/mm/yyyy string to a Date object in JavaScript, here’s what you need to do: A date string in dd/mm/yyyy format is considered a non-standard date format in JavaScript. That said, it isn’t a good idea to ...
⤳ The error “TypeError: getElementById is not a function” happens for two common reasons (Based on StackOverflow users): Here’s what this error looks like in the browser’s console: How to fix the “TypeError: getElementById is not a function” error Before anything, let’s have a refresher from ...
⤳ 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 ...
⤳ The error “Cannot use import statement outside a module” occurs when you use the import statement outside an ES (ECMAScript) module. If you’re using Node.js, you need to set Node’s module system to ES modules – by adding type: "module" to your package.json (note the ...