Why Python 3.6.1 throws AttributeError: module ‘enum’ has no attribute ‘IntFlag’?

It’s because your enum is not the standard library enum module. You probably have the package enum34 installed. One way check if this is the case is to inspect the property enum.__file__ Since python 3.6 the enum34 library is no longer compatible with the standard library. The library is also unnecessary, so you can simply uninstall it. If you need the code … Read more

‘pip3’ is not recognized as an internal or external command, operable program or batch file

On Windows, it’s a good idea to stick to launching pip via the py.exe common launcher, so you can provide flags to specify which version of Python to use without needing to deal with a complicated PATH. To use it for Python 3, just replace: with: It’s a little bit longer to type, but it avoids a lot of hassles with PATH management, … Read more

enumerate() for dictionary in python

On top of the already provided answers there is a very nice pattern in Python that allows you to enumerate both keys and values of a dictionary. The normal case you enumerate the keys of the dictionary: Which outputs: But if you want to enumerate through both keys and values this is the way: Which outputs:

Infinite integer in Python

Taken from here: https://www.gnu.org/software/libc/manual/html_node/Infinity-and-NaN.html IEEE 754 floating point numbers can represent positive or negative infinity, and NaN (not a number) That is, the representation of float and Decimal can store these special values. However, there is nothing within the basic type int that can store the same. As you exceed the limit of 2^32 in an unsigned 32-bit int, you simply roll … Read more

Get ZeroDivisionError: float division in python

The problem is here: You are dividing two integers, so python is using integer division. In integer division, the quotient is rounded down. For example, 364/365 would be equal to 0. (365/365 works because it is equal to 1, which is still 1 rounded down.) Instead, use float division, like so.