⤳ 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 ...
⤳ 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 ...