Hello, I've loved Python ever since I picked it up a couple years ago, but I have a question about the proper way to do something. There's a way of condensing an if/else conditional that has 2 options (True, False), for simple things.
Assume that playerWins
is a boolean:
if playerWins:
print 'You win!'
else:
print 'You lose...'
Now, this can also be executed just as easily by writing:
[ print 'You lose...', print 'You win!' ][ playerWins ]
Which way is the proper way? I'm assuming that the first one is due to it being slightly more readable (a nice goal of Python), but if I'm looking to condense simple things in my code like this, is it wrong to use the second way? And what about speed? Is there any difference in efficiency between these two?
I'm self-taught so I never had anyone explicitly tell me these fine details of Python, but if anyone knows the 'standard' for this sort of thing, can you let me know? Thanks!