Created
February 13, 2015 01:52
-
-
Save dhduvall/2941052f8b07826bd390 to your computer and use it in GitHub Desktop.
Creating variables dynamically
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
| laps = ["first", "second", "third", "fourth"] | |
| for i, lap in enumerate(laps): | |
| exec("lap_%s='%s'" % (i, lap)) | |
| print lap_0 # first | |
| print lap_3 # fourth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment