[Tutor] how to tell if strings have numbers in them
Thu, 4 Jan 2001 19:20:26 +0200 (IST)
On Wed, 03 Jan 2001 18:14:18 -1000, Brett <firstname.lastname@example.org> wrote:
> I'm trying to get input and checking to see if it's a number. x==int(x)
> works if it is a number, but causes an error if you input a string. I made
> a list of 0-9 and tried for z in x/if z in list, and that seems to work,
> but its takes a lot of typing, is there an existing function that can check
> to see if a variable is a number?
I usually use:
is_integer = re.compile('[0-9]+').match
I'm not sure what you mean by a number (float? scientific notation? negative?)
Moshe Zadka <email@example.com>
This is a signature anti-virus.
Please stop the spread of signature viruses!