⤳ The Python error “TypeError: can only concatenate str (not “list”) to str” occurs if you concatenate a string with a list. Here’s what the error looks like on Python 3. On Python 2.7, the error is slightly different, though: But it occurs for the same ...
⤳ 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 ...
⤳ 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 ...