[Tutor] checking if a variable is an integer?
Peter Lavelle
lists at solderintheveins.co.uk
Tue May 31 23:46:24 CEST 2011
I think you could also use the type() function. See example below:
if type(yourvar) == int:
#Do stuff here if it is an integer
else:
#Do something here if it is not an integer
Regards
Peter
On 31/05/11 22:23, Hans Barkei wrote:
> I want to make a program that finds all the prime numbers up to a
> number inputed by the user.
> I want to know if it is an integer because that will tell me if it is
> divisible by that number or not.
> ***---------**/Hans/-----*
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110531/d02e1d3a/attachment.html>
More information about the Tutor
mailing list