-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpokeapi.py
More file actions
29 lines (19 loc) · 755 Bytes
/
pokeapi.py
File metadata and controls
29 lines (19 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
# Como buena práctica podemos separar la URL base, y la URI en variables
# Que devuelva también todos sus movimientos
#jsonEditorOnline
num_poke = str(input("Dame un número de pokemon \n"))
def tomaPokemon(pokemon):
BASE_URL = "http://pokeapi.co/api/v2/"
URI_POKEMON_1 = "pokemon/" + pokemon
URL = BASE_URL + URI_POKEMON_1
response = requests.get(URL)
diccionario = response.json()
resultado = diccionario['forms'][0]['name']
# resultado = diccionario['moves'][0]['move']['name']
for i in range(0,len(diccionario['moves'])):
print(diccionario['moves'][i]['move']['name'])
return resultado
x = tomaPokemon(num_poke)
print(x)
#print(diccionario['game_indices'][13]['version']['name'])