Skip to content

Instantly share code, notes, and snippets.

@secnot
Created February 21, 2017 22:19
Show Gist options
  • Save secnot/716fd4e7722c838d71543a18b054d4b1 to your computer and use it in GitHub Desktop.
Save secnot/716fd4e7722c838d71543a18b054d4b1 to your computer and use it in GitHub Desktop.
Get the nth digit of an integer
def digit(num, n):
"""Returns nth digit of num (both integers)"""
return abs(num)//10**n%10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment