Re: [Tutor] Checking that the input is float()-able

2013-09-22 Thread Amit Saha
On Sun, Sep 22, 2013 at 11:28 AM, Steven D'Aprano wrote: > On Sun, Sep 22, 2013 at 10:18:23AM +1000, Amit Saha wrote: >> Hi all, >> >> I want my program to report an error if anything other than a number >> which I can then convert to float using float() is entered as input: >> >> # Python 3 >> tr

Re: [Tutor] Checking that the input is float()-able

2013-09-21 Thread Steven D'Aprano
On Sun, Sep 22, 2013 at 10:18:23AM +1000, Amit Saha wrote: > Hi all, > > I want my program to report an error if anything other than a number > which I can then convert to float using float() is entered as input: > > # Python 3 > try: > a = float(input('Enter a number: ')) > > except ValueEr

Re: [Tutor] Checking that the input is float()-able

2013-09-21 Thread Joel Goldstick
On Sat, Sep 21, 2013 at 8:18 PM, Amit Saha wrote: > Hi all, > > I want my program to report an error if anything other than a number > which I can then convert to float using float() is entered as input: > > # Python 3 > try: > a = float(input('Enter a number: ')) > > except ValueError: >

[Tutor] Checking that the input is float()-able

2013-09-21 Thread Amit Saha
Hi all, I want my program to report an error if anything other than a number which I can then convert to float using float() is entered as input: # Python 3 try: a = float(input('Enter a number: ')) except ValueError: print('Wrong input') else: print('Right input') This seems to do