mardi 30 janvier 2018

in the way of understanding return in python? what is the difference Here?

please explain in details as much as You can

why that is True?

def array_front9(nums):
    for i in nums[:4]:
        if i == 9:
            return True
    return False

array_front9([1, 2, 9, 3, 4])

while this is False:

def array_front9(nums):
    for i in nums[:4]:
        if i == 9:
            return True
        else:
            return False

array_front9([1, 2, 9, 3, 4])

Aucun commentaire:

Enregistrer un commentaire