To return the day of the week from a string, you have to import the datetime module and run this code:Continue reading
The easiest way to sort letters is to use the join and sorted functions together.Continue reading
There are two methods in Python that can add an element to a list: append and extend. These methods can cause a lot of confusion among beginner Python programmers.Continue reading
If you work with dictionaries, sometimes, you will have to check whether a dictionary is empty.Continue reading
In Python, you can add dictionary keys to a list. This can be achieved with the keys function of a dictionary.Continue reading
To import the current date (year, month, day) and time (hour, minute, second), you have to import the datetime module.Continue reading
Contrary to other programming languages, such as C++ or Java, you don’t specify the data type when defining a variable in Python, but it doesn’t mean that the variable doesn’t have a type.
You can check the variable type using the type function that returns the type of data.Continue reading
If you add a dictionary to a list in Python, it won’t create a copy of this dictionary, but rather add a reference to the dictionary.Continue reading
If you create a variable, you can easily convert it to a string using the print function.
a = 5 print(a)
sys.maxint is the maximum value for the int variable in Python 2.
Python 3 doesn’t use this property because the int type in Python 3 has no limit. For Python 3, you can use sys.maxsize to check the maximum size lists, strings, dicts, and many other containers can have.Continue reading