How to test if a variable has a natural number?
dtrahan at cfl.rr.com
Thu Jun 12 00:53:24 CEST 2003
Martin P<martin_p at despammed.com> wrote:
> how can I find out if the number of a variable
> is a natural number or not?
I'll asume that by "find out if the number of a variable
is a natural number or not" you are asking how to determine whether the
number a varible is set to is a Natural Number (ie in the set of whole
positive numbers; a positive integer).
If this is the case here we go:
if x >= 1 & x % 1 == 0:
print "Varible is set to a NATURAL"
print "Varible is NOT set to a natural"
run this lil snippet with the name of your varible as arg x
-- Jack Daniel
More information about the Python-list