python function returning dictonary

Solutions on MaxInterview for python function returning dictonary by the best coders in the world

showing results for - "python function returning dictonary"
Noelle
07 Sep 2020
1def query(id):
2    for line in file:
3        table = {}
4        (table["ID"],table["name"],table["city"]) = line.split(";")
5        if id == int(table["ID"]):
6             file.close()
7             return table
8    # ID not found; close file and return empty dict
9    file.close()
10    return {}
11