This question already has an answer here:
An if/else can be written as such:
if <condition>:
variable = <value>
else:
variable = <other value>
But the same can be achieved by:
variable = <other value>
if <condition>:
variable = <value>
Is there a meaningful argument as to which is preferred? Or does it come down to personal preference?
Note: I know in Python you could also do:
variable = <value> if <condition> else <other value>
I'm only concerned about syntax.
Aucun commentaire:
Enregistrer un commentaire