Raw_input variable does not prompt



My code goes on an infinite loop;

I would expect the code to ask me for a number; but it never does. Because of that I think that the while loop becomes infinite, as x is never a float.
Why does this not work?

def is_even(x):
    x = raw_input("Write a number.")
    while x != float:
        print "That is not a number!"
        x = raw_input("Write a number.")
    if x/2 == int:
        return True
        return False

Also, if I modify the code to only accept float as inputs (x=float(raw_input("..."))), it says it can't convert a string to a float, but as I've said before, the actual thing never prompts. Why is that?


You wrote a method, you have to call that method after:



I can't believe it was something so simple. Thanks a lot!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.