Created
August 18, 2020 02:58
-
-
Save Bradysm/88b6cf3329b42533fc2b435e6a2ef3ba to your computer and use it in GitHub Desktop.
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 find_all_numbers(): | |
# create regex and then compile it into a regex object | |
regex = r'[+-]?\d+' | |
pattern = re.compile(regex) | |
# ask for an input from the user | |
input_str = input("Enter a string with numbers: ") | |
# find all numbers within the string using the regex | |
print("\nALL NUMBERS WITHIN THE STRING:") | |
for num in pattern.findall(input_str): | |
print(num) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment