Simple syntax not working


#1

I expected this code to return the print statement when I ran it but it just gives me a blank output....would anyone happen to know why? seems like such a simple block of code :confused:

number=raw_input('what would you like to evaluate?')
if number>=9 and number<=30 and number%2==0:
    print 'that\'s a fairly big even number!'

#2

and yet it is so complex, there is something happening which you don't know, raw_input doesn't give you a integer:

number=raw_input('what would you like to evaluate?')
print type(number)
number = int(number)
if number>=9 and number<=30 and number%2==0:
    print 'that\'s a fairly big even number!'

on line two, i ask python: print me the type of number, and it will say unicode, not integers (which we want), so i cast it to a integer, now it is a integer and your if condition should work

One drawback: You will get an error if the input can't be cast to a integer. Hope this helps


#3

yes it did! thanks so much ! I wasn't aware that raw_input needed to be configured to that degree