Skip to content

Instantly share code, notes, and snippets.

@viasnake
Created May 11, 2021 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viasnake/f41d5e83b9ea0d17d6090f91664df1e3 to your computer and use it in GitHub Desktop.
Save viasnake/f41d5e83b9ea0d17d6090f91664df1e3 to your computer and use it in GitHub Desktop.
Python program to extract a specified number of digits from a specified number of digits.
"""
Input:
1234567891
5
3
Output:
567
"""
string = int(input())
start_str = int(input())
digit = int(input())
string_digit = int(len(str(string)))
a = int(string / 10 ** (string_digit - start_str - digit + 1))
b = int(a / 10 ** digit)
b = b * 10 ** digit
result = a - b
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment