Created
May 5, 2016 17:42
-
-
Save reeddunkle/bd9671b802ad53656dcccf34673ed427 to your computer and use it in GitHub Desktop.
List Comprehension Exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| This is hacky and ugly. It only works because both | |
| lists are the same size, etc. etc. | |
| Upon researching this, it seems that this is an example | |
| when map() is actually way better and preferable. | |
| There's also a function called zip() which does this, | |
| but I haven't learned zip() yet. | |
| I'll write about it when I do. I hear it's simple. | |
| ''' | |
| NUMBERS = range(4) | |
| NAMES = ['Rebecca', 'Georgi', 'Reed', 'Thom Yorke'] | |
| result = [(NUMBERS[i], NAMES[i]) for i in range(len(NUMBERS))] | |
| print result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment