lundi 28 mars 2016

Can someone tell me why this recursive method with raw_input is not returning?

Here is the statement:

def recursive(y):
    if y < 10:
        return y
    else:
        z = raw_input("Please enter a number: ")
        recursive(z)

x = raw_input("Please enter a number: ")
t = recursive(x)

print t

Whenever I run this, if I enter a number equal to or above 10, it prompts me to enter a number again. If I enter a number less than 10, it still tells me to enter a number; however, if I enter less than 10, shouldn't the if y < 10 be true and it will return that number?

Aucun commentaire:

Enregistrer un commentaire