Raw_input variable does not prompt


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/2?curriculum_id=4f89dab3d788890003000096

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
    else:
        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?


#2

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

is_even(your_number)


#3

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


#4

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