Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    As of Python 3.5, you can write infinity as math.inf (having put import math in your imports), and negative infinity as -math.inf. Commented Nov 22, 2019 at 11:44
  • @ArthurTacca, type(math.inf) is float and not int. Commented Jan 4, 2022 at 22:10
  • 1
    @Christian You are right. math.inf is now better than writing float('inf') as suggested in this answer. However, it gives the same actual value, it doesn't answer the original question any better. I hadn't meant to suggest that it does, but I can see that my comment didn't make that clear. Commented Jan 6, 2022 at 17:03