Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Bonsai Boy of New York Bonsai Trees and Accessories

BlueHost Web Hosting

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

11,402 questions

15,552 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 by avibootz
edited Jun 29 by avibootz