Saturday, 8 June 2013

Is it more pythonic to use in operator vs or operator

Is it more pythonic to use in operator vs or operator

Which of these statements is more pythonic? If I added more comparisons, would one become more useful than the other?
if(card3 == game_data['card1'] or card3 == game_data['card2'])
Or
if (card3 in [game_data['card1'],  game_data['card2']])

No comments:

Post a Comment