vendredi 26 octobre 2018

Why is the output different from these two?

Why is this code wrong :

def parrot_trouble(talking, hour):
  if talking == True and hour < 7 or hour > 20:
    return True
  else : 
    return False

And why is this code right:

def parrot_trouble(talking, hour):
  if talking == True and (hour < 7 or hour > 20):
    return True
  else : 
    return False

Aucun commentaire:

Enregistrer un commentaire