Last active
May 22, 2023 08:24
-
-
Save ltpitt/0cbe74ad668c4827953b49c646c3253c to your computer and use it in GitHub Desktop.
A simple Python snippet to find out if a name is a Pokemon or not.
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
import requests | |
topics = 'bulbasaur, go, pikachu, html' | |
findings = {} | |
for topic in topics.split(','): | |
topic = topic.strip() | |
result = requests.get(f'https://pokeapi.co/api/v2/pokemon/{topic}') | |
if result.text == 'Not Found': | |
findings[topic] = 'is not a pokemon' | |
else: | |
findings[topic] = 'is a pokemon' | |
for topic, finding in findings.items(): | |
print(f'{topic} {finding}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment