Skip to content

Instantly share code, notes, and snippets.

@rytoj
Created March 24, 2018 10:28
Show Gist options
  • Save rytoj/ce99b9cde9eca607fe3d4f15c45f3eb0 to your computer and use it in GitHub Desktop.
Save rytoj/ce99b9cde9eca607fe3d4f15c45f3eb0 to your computer and use it in GitHub Desktop.
python examples
# List complehensions zipping elements
ranks
['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', 'J', 'Q', 'K', 'A']
suits
['spades', 'diamonds', 'clubs', 'heats']
[(rank, suit) for rank in ranks for suit in suits]
[('2', 'spades'), ('2', 'diamonds'), ('2', 'clubs'), ('2', 'heats'), ('3', 'spades'), ('3', 'siamonds'), ('3', 'clubs'), ('3', 'heats'), ('4', 'spades'), ('4', 'siamonds'), ('4', 'clubs'), ('4', 'heats'), ('5', 'spades'), ('5', 'siamonds'), ('5', 'clubs'), ('5', 'heats'), ('6', 'spades'), ('6', 'siamonds'), ('6', 'clubs'), ('6', 'heats'), ('7', 'spades'), ('7', 'siamonds'), ('7', 'clubs'), ('7', 'heats'), ('8', 'spades'), ('8', 'siamonds'), ('8', 'clubs'), ('8', 'heats'), ('9', 'spades'), ('9', 'siamonds'), ('9', 'clubs'), ('9', 'heats'), ('10', 'spades'), ('10', 'siamonds'), ('10', 'clubs'), ('10', 'heats'), ('11', 'spades'), ('11', 'siamonds'), ('11', 'clubs'), ('11', 'heats'), ('J', 'spades'), ('J', 'siamonds'), ('J', 'clubs'), ('J', 'heats'), ('Q', 'spades'), ('Q', 'siamonds'), ('Q', 'clubs'), ('Q', 'heats'), ('K', 'spades'), ('K', 'siamonds'), ('K', 'clubs'), ('K', 'heats'), ('A', 'spades'), ('A', 'siamonds'), ('A', 'clubs'), ('A', 'heats')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment