Skip to content

Instantly share code, notes, and snippets.

@Geekfish
Created March 26, 2013 11:11
Show Gist options
  • Save Geekfish/5244638 to your computer and use it in GitHub Desktop.
Save Geekfish/5244638 to your computer and use it in GitHub Desktop.
Get a mapping of the reverse values of a given range (1 to 5 here). Improved versions welcome.
{val: range(5, 0, -1)[key] for key, val in enumerate(range(1, 6))}
# {1: 5, 2: 4, 3: 3, 4: 2, 5: 1}
@Geekfish
Copy link
Author

As pointed by @docmatrix

str(-1 * int(old_val) + 6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment