Skip to content

Commit

Permalink
Reto mouredev#10 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAntonioRuizGarcia committed Dec 8, 2023
1 parent c926d16 commit 58ce695
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Retos/Reto #10 - LA API [Media]/python/JoseAntonioRuizGarcia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import requests

def queryPokemon(pokemon: str) -> None:
res = requests.get(
f'https://pokeapi.co/api/v2/pokemon/{pokemon}'
)
if res.ok:
name = res.json()['species']['name']
type = res.json()['types'][0]['type']['name']
weight = res.json()['weight']

print(f'El Pokemon {name} es de tipo {type} y pesa {weight}')

else:
print(f'El Pokemon {pokemon} no se encuentra en la API.')

if __name__ == '__main__':
queryPokemon('ditto')
queryPokemon('pikachu')
queryPokemon('charrizard')

0 comments on commit 58ce695

Please sign in to comment.