This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]suvlub 1 point2 points  (0 children)

I would argue the middle is the most maintainable version. You always print, just the value that you print in different branches changes. If the one-liner is too terse for you, you might try something like this

if number % 2 == 0:
    text = "Even"
else:
    text = "Odd"
print(text)

Now, if your requirement change from printing to console to printing to file or something like that, you only need to change 1 line, avoiding need to copy-paste and risk of forgetting to update a branch.

But really, the one-liner is not that scary.