by Suf | Feb 26, 2022 | Programming, Python, Tips
If you try to access a closed file, you will raise the ValueError: I/O operation on closed file. I/O means Input/Output and refers to the read and write operations in Python. To solve this error, ensure you put all writing operations before closing the file. This...
by Suf | Feb 26, 2022 | DSA, Programming, Python, Tips
Bubble sort is a popular sorting algorithm that compares the adjacent elements in a list and swaps them if they are not in the specified order. This tutorial will go through how to implement the bubble sort algorithm in Python with the help of code examples. Got some...
by Suf | Feb 25, 2022 | Programming, Python, Tips
The error TypeError: unhashable type: ‘set’ occurs when trying to get a hash of a set object. For example, using a set as a key in a dictionary. To solve this error, we can cast the set to a frozenset or a tuple, which are both hashable container objects. This...
by Suf | Feb 24, 2022 | Programming, Python, Tips
The error TypeError: unhashable type: ‘numpy.ndarray’ occurs when trying to get a hash of a NumPy ndarray. For example, using an ndarray as a key in a Python dictionary because you can only use hashable data types as a key. We can use the update() method to...
by Suf | Feb 23, 2022 | Programming, Python, Tips
The error TypeError: unhashable type: ‘list’ occurs when trying to get a hash of a list. For example, using a list as a key in a Python dictionary will throw the TypeError because you can only use hashable data types as a key. To solve this error, you can...
by Suf | Feb 23, 2022 | Programming, Python, Tips, Uncategorized
In Python, the list data structure stores elements in sequential order. The numpy.shape() function gives us the number of elements in each dimension of an array. We cannot use the shape function on a list. If we try to use the numpy.shape() function on a list, you...