by Suf | Mar 11, 2022 | Programming, Python, Tips
This error typically occurs when you try to read the string pointing to the path of a file instead of a file object. To solve this error, you should use the appropriate method for reading the path of a file or reading a file object. Generally, when reading in an...
by Suf | Mar 10, 2022 | Programming, Python, Tips
In Python, a tuple is a built-in data type used to store collections of data. A tuple is a collection that is ordered and unchangeable. Once you create a tuple, you cannot add or remove items. The append() method appends an element to the end of a list. If you call...
by Suf | Mar 9, 2022 | Programming, Python, Tips
In Python, a list is a built-in data type used to store collections of data. We can convert a list of strings to a string using the join() method. The join is a string method, not a list method. If we call the join method on a list like list.join(), we will raise the...
by Suf | Mar 9, 2022 | Programming, Python, Tips
In Python, a dictionary stores data values in key-value pairs. If you use the append() method to add new values to a dictionary, you will raise the AttributeError: ‘dict’ object has no attribute append. The append() method belongs to the list data type and...
by Suf | Mar 9, 2022 | Programming, Python, Tips
To define a dictionary in Python, you need to use curly brackets with the keys and values separated by colons. If you use commas between keys and values, you create a set. Then when you try to use the dictionary method items on the set, you will raise the...
by Suf | Mar 8, 2022 | Programming, Python, Tips
To define an empty set in Python 3, you need to use the built-in set() function. If instead, you use the curly brackets {}, you are creating an empty dictionary. Then when you try to use the set method add on the empty dictionary, you will raise the AttributeError:...