Created
May 11, 2021 06:51
-
-
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.
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
""" | |
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