Created
November 2, 2023 06:50
-
-
Save cherkaskyb/b319bbb298d10b742af1fc9164725be6 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
from typing import List, Optional | |
import requests | |
def explode_and_filter_by_threshold(value: str, threshold: int) -> List[int]: | |
""" | |
Params: | |
- value : a string of numbers separated by comma | |
- threshold : numerical threshold | |
returns an array of all values > threshold | |
""" | |
values = map(lambda x: int(x), value.split(",")) | |
return list(filter(lambda x: x >= threshold, values)) | |
def http_request() -> Optional[str]: | |
""" | |
Executes an Http GET request to example.com | |
If response code is any other than 200 - it returns None. | |
""" | |
result = requests.get( | |
"https://example.com" | |
) | |
if result.status_code != 200: | |
return None | |
return result.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment