Hi, this is my code:
def items_string(items_list):
"""Convert a list of Id, number pairs into a string representation.
items_string(list((str, int))) -> str
"""
result = []
for item_id, num in items_list:
result.append("{0}:{1}".format(item_id, num))
return ','.join(result)
class Compound(Item):
def __init__(self,item_id,name,products,items_list):
Item.__init__(self,item_id,name)
self.products=products
self.items_list=items_list
def __repr__(self):
self.items_list=items_string(self)
return '{0},{1},{2}'.format(self.item_id,self.name,self.items_list)
class Products:
def __init__(self):
self.mydict={}
def get_item(self,item_id):
return self.mydict[item_id]
When I enter this in IDLE:
products = Products()
products.add_item('CWH111', Compound('CWH111','Mountain Bike Built Wheel', products,[('TR202', 1), ('TU227', 1), ('WH239', 1)]))
products.get_item('CWH111')
I get this error:
for item_id, num in items_list:
TypeError: iteration over non-sequence
How can I fix this?