vendredi 29 novembre 2019

Position of 'if' in statement

is there a difference between:

  1. if x > 0: print x
  2. print x if x > 0

Is the 2nd option preferred when the if statement is embedded in other code? If not in what are the situations where one is preferred over the other?

Aucun commentaire:

Enregistrer un commentaire