Skip to content

Instantly share code, notes, and snippets.

@ltpitt
Last active May 22, 2023 08:24
Show Gist options
  • Save ltpitt/0cbe74ad668c4827953b49c646c3253c to your computer and use it in GitHub Desktop.
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.
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