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:...
by Suf | Mar 8, 2022 | Programming, Python, Tips
We use dictionaries to store data values in key-value pairs in Python. The dictionary method iteritems() returns an iterator of the dictionary’s list as key-value tuple pairs. As of Python major version 3, the items() method replaced iteritems(). If you try to...