[Tutor] Simple User Entry Verification

Kent Johnson kent37 at tds.net
Sun Mar 15 14:20:04 CET 2009


On Sat, Mar 14, 2009 at 5:52 PM, R. Alan Monroe <amonroe at columbus.rr.com> wrote:
>
>> while type(start)!=float:
>
> Did you try quotes around the word "float"?

That won't help, type(start) is a type object, not a string.

It's also possible that Ian is entering an integer, he didn't show the
input value:
In [1]: print type(input('Enter a number: '))
Enter a number: 123
<type 'int'>

Alan G's solution - explicit conversion using float() with an
exception handler - is the best way to do this.

Kent


More information about the Tutor mailing list