Skip to content

Instantly share code, notes, and snippets.

@dhduvall
Created February 13, 2015 01:52
Show Gist options
  • Select an option

  • Save dhduvall/2941052f8b07826bd390 to your computer and use it in GitHub Desktop.

Select an option

Save dhduvall/2941052f8b07826bd390 to your computer and use it in GitHub Desktop.
Creating variables dynamically
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