How to not iterate in a dictionary? How to get the key?
import json import requests from pprint import pprint def get_address(pendientes): #I want to improve function get_address and #get_addressv2. Specifically, I do not want to iterate in a #dictionary. Please help me. try: llaves = list(pendientes.keys()) print(llaves[3]+":",pendientes["age"]) except: print("Problemas en la función get_address") def get_addressv2(pendientes): #Proof that you cannot iterate in orden in a dicitionary try: key = list(pendientes.items())[1] print(key) except: print("Problemas en la función get_addressv2") def iteraccion(pendientes): for keys in pendientes.keys(): if keys =="age" : print(keys, ":", pendientes["age"]) def print_completeAddress(pendientes): for k,v in pendientes["address"].items(): print(k,":",v) def main(): try: input= "https://tools.learningcontainer.com/sample-json.json" response=requests.get(input) pendientes = json.loads(response.text) #pprint(pendientes) Si desea ver le Json descomente esta línea. get_address(pendientes) except: pprint("Problemas de cargue de JSON") if __name__== "__main__" : main() !!!Please help me to optimize this code and not to try to iterate in the dictionary"