Go With the Flow


Hello guys,

I have a problem with the first part of conditionals and control flow.
I changed it fo experiment a little bit.

Here is my code, but it does not work properly:

def clinic():
    print "This program will check how good a student you are!"
    answer=raw_input("What mark did you get for coding?")
    if answer >= 7:
        print "You are a very good student!"
    elif answer <= 7 :
        print "You should learn better!"
        print "You didn't enter a mark! Try again."

It will always say that I am a very good student. Why is that????

I Hope someone can help me. Thanks in advance


what you didn't know, is that raw_input gives you a unicode, which we can see if we add a simple print statement:

answer=raw_input("What mark did you get for coding?")
print type(answer)

Now, you actually want to a integer (non decimal number), we can use a simple cast to fix this:

answer=int(raw_input("What mark did you get for coding?"))
print type(answer)



you are calling the clinic() from within
causing an inifinite loop !!!!


But that is if the user enters a invalid mark, so that is a good thing?


Thanks! You Are The Best, man!