samedi 18 juin 2016

problems with if in a function

I am doing a simple program just to the program say if a number is even or not and to when the raw_input isn't a number, the program will complain about it:

def f():
    t = raw_input('Enter a number and we will send an inormation: ')


if t != type(int):
    print 'is this a number?'

elif int(t) % 2 == 0:
    print t
    print 'it is an even number'

elif int(t) % 2 > 0:
     print t
     print 'it is an odd number'

else:
     print '???'

but when the program run it returns ONLY the if condition (when i write 90 or a word it returns 'is this a number?'. it should only return this if I Write a string). And I can't figure out where is the problem.

Aucun commentaire:

Enregistrer un commentaire