Skip to content

Instantly share code, notes, and snippets.

@kaecy
Created January 10, 2022 11:43
Show Gist options
  • Save kaecy/c2dbd84580145df0101eafe70bdde04c to your computer and use it in GitHub Desktop.
Save kaecy/c2dbd84580145df0101eafe70bdde04c to your computer and use it in GitHub Desktop.
import requests
def basicInfo(pokemon):
res = requests.get("https://pokeapi.co/api/v2/pokemon/" + pokemon)
json = res.json()
name = json['name']
id = json['id']
moves = []
index = 0
while (len(moves) < 4):
moveLearnedAt = json['moves'][index]['version_group_details'][0]['level_learned_at']
if moveLearnedAt > 0 and moveLearnedAt < 15:
moves.append(json['moves'][index]['move']['name'])
index += 1
print("Name:", name)
print("ID:", id)
print("Moves:", ", ".join(moves))
basicInfo("bulbasaur")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment