Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
BlueHost Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting

getResponse autofunnels

Liquid Web Cloud VPS Hosting

Disclosure We are a professional Information website that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

12,128 questions

16,523 answers

573 users

How to use isfinite() to check if regular numbers or special values inf or nan in Python

1 Answer

0 votes
import math       

for f in [0.0, 1.0, math.e, math.pi, math.nan, math.inf]:           
    print('{:4.2f} {!s}'.format(f, math.isfinite(f)))


0.00 True
1.00 True
2.72 True
3.14 True
 nan False
 inf False



answered Jun 29, 2019 by avibootz
edited Jun 29, 2019 by avibootz