Skip to content

Instantly share code, notes, and snippets.

@cherkaskyb
Created November 2, 2023 06:50
Show Gist options
  • Save cherkaskyb/b319bbb298d10b742af1fc9164725be6 to your computer and use it in GitHub Desktop.
Save cherkaskyb/b319bbb298d10b742af1fc9164725be6 to your computer and use it in GitHub Desktop.
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