by Suf | Jan 21, 2022 | Programming, Python, Tips
There are two types of arguments in Python: keyword and positional arguments. The syntax of Python requires that these types of arguments appear in a particular order. If you place a positional argument after a keyword argument, the Python interpreter will throw the...
by Suf | Jan 19, 2022 | Programming, Python, Tips
In Python, we use __init__() as a constructor function when creating an object of a class. This function allows you to pass arguments to a class object. If you misspell the __init__ function, you will encounter the error: TypeError: object() takes no arguments. To...
by Suf | Jan 18, 2022 | Programming, Python, Tips
The Python map() function applies a function on all items in an input iterable object. The iterable object can be a list, a tuple, a set, dictionary or a string. The map() function returns an iterable map object, which you will have to iterate over using a for loop or...
by Suf | Jan 17, 2022 | Programming, Python, Tips
In Python, you can unpack iterable objects and assign their elements to multiple variables in the order that they appear. If you try to unpack a NoneType object, you will throw the error TypeError: cannot unpack non-iterable NoneType object. A NoneType object is not a...
by Suf | Jan 16, 2022 | Programming, Python, Tips
The join() takes all items in an iterable and joins them into one string. If you attempt to pass a non-iterable object to the join() method, you will raise the error: Python TypeError: can only join an iterable. You can solve this by ensuring that you do not assign...
by Suf | Jan 16, 2022 | Programming, Python, Tips
If you try to index a Python list with an array of integer values you will raise the error: TypeError: only integer scalar arrays can be converted to a scalar index. You can only index an ordinary Python list with single integer values. If you want to use an array of...