Home > Net >  Python dictionary - more optimal
Python dictionary - more optimal

Time:02-25

How could I make this code more optimal, not to have repetition?

for item in my_dict["environment"]:
    item.update({"service": service})
    item.update({"project_name": project})
    item.update({"arti_path": arti_path})

CodePudding user response:

Did you mean:

item.update({"service": service, "project_name": project, "arti_path": arti_path})
  • Related