Created
January 10, 2022 11:43
-
-
Save kaecy/c2dbd84580145df0101eafe70bdde04c to your computer and use it in GitHub Desktop.
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 | |
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