Answers for "python function returning dictonary"

0

python function returning dictonary

def query(id):
    for line in file:
        table = {}
        (table["ID"],table["name"],table["city"]) = line.split(";")
        if id == int(table["ID"]):
             file.close()
             return table
    # ID not found; close file and return empty dict
    file.close()
    return {}
Posted by: Guest on February-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language