Created
February 21, 2017 22:19
-
-
Save secnot/716fd4e7722c838d71543a18b054d4b1 to your computer and use it in GitHub Desktop.
Get the nth digit of an integer
This file contains 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
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