hi based on this code:
def load_products(filename):
def get_components(parts):
"""parts is a list of parts and their associated amounts, each separated into groups, split by (',')"""
"""need to take out each id, take out each integer, an associate them, by putting them in a pair -> return in big list"""
"""turn 'parts' into a string"""
partss = "".join(parts)
""" -> Reference: 'http://mail.python.org/pipermail/tutor/2005-May/038160.html'"""
info = partss.split(':')
parts_list = []
for l in info:
parts_list.append(info)
return parts_list
filename = ('products.txt')
o = open(filename, 'U')
product_dict = {}
for line in o:
split_line = line.split(',')
global ID
"""ID is referenced elsewhere"""
ID = split_line[0]
global name
"""name is referenced elsewhere"""
name = split_line[1].strip()
global parts
"""parts is referenced elsewhere"""
parts = split_line[2:][:-2]
get_components(parts)
product_dict[ID] = name, parts
o.close()
return product_dict]
i need to write a function that will allow a user to search by ID, and get name, and a function that will search by name and return an id does anyone know how i can do this?