mercredi 25 avril 2018

When i run this code snippet several times which generates a random even number in python it prints "None" for some times. Why is this happening?

When i run this code several times it prints "None" for some times. Why is this happening

import random
def randomeven():
    n=int(r.random()*100)
    if n%2==0:
       return n
    else:
       randomeven()

print(randomeven())




Aucun commentaire:

Enregistrer un commentaire