import json import requests p_list = 'https://pokeapi.co/api/v2/pokemon/' p_data = [] x=885 def strongest(f_p_request,f_data): p_data.append([f_p_request.json()["name"], f_p_request.json()[f_data]]) #for i in range(10): while True: print(x) p_request=requests.get(p_list+str(x)) if (p_request.status_code!=200): break strongest(p_request,"base_experience") x+=1 p_data.sort(key=lambda x: (x[1] is not None, x[1]),reverse=True) print ('\nliczba pokemonów = '+str(x-1)) print ('\nnajsilniejsze pokemony:\n') for i in range(5): print(p_data[i][0],'Sila=',p_data[i][1])