Created
July 1, 2022 18:39
-
-
Save po5i/a1c4719ec9cae3a2977fd09a9593d0e4 to your computer and use it in GitHub Desktop.
Print the list of repos for a specific user
This file contains hidden or 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
import requests | |
BASE_URL = "https://api.github.com/users/{}/repos" | |
def get_repos(username: str) -> None: | |
response = requests.get(BASE_URL.format(username)) | |
try: | |
print(f"Repositories from {username}:") | |
print([repo["name"] for repo in response.json()]) | |
except Exception as e: | |
print(f"Error: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment