#!/usr/bin/python3 # Description: How to check if a string is a number. def isNumber(str): try: float(str) return True except ValueError: return False s = "1234" print("is {} a number = {}".format(s, isNumber(s))) s = "100.99" print("is {} a number = {}".format(s, isNumber(s))) s = "-5.66" print("is {} a number = {}".format(s, isNumber(s))) s = "01234" print("is {} a number = {}".format(s, isNumber(s))) s = "y1234" print("is {} a number = {}".format(s, isNumber(s)))