Noob python question for pros
Posted: Fri Jul 07, 2017 10:48 pm
Hello again!
I'm trying to build a refrigerator inventory system based on the inventory example from this forum but theres something I'm not getting with arrays in python. I'm pretty sure I dont understand how to parse an array. Bellow is my code I think its related between this :
$ sorted_foods = sorted(refrigerator.foods, key=attrgetter('name'), reverse=False)
and this :
for foods in sorted_foods:
But I dont see why...
I know my object is working and I can add items to it (I tried with a if(pizza in refrigerator.foods) in a menu and it works). I have an item in my refrigerator object but still, this code is not working.
Thank you for your time!
I'm trying to build a refrigerator inventory system based on the inventory example from this forum but theres something I'm not getting with arrays in python. I'm pretty sure I dont understand how to parse an array. Bellow is my code I think its related between this :
$ sorted_foods = sorted(refrigerator.foods, key=attrgetter('name'), reverse=False)
and this :
for foods in sorted_foods:
But I dont see why...
I know my object is working and I can add items to it (I tried with a if(pizza in refrigerator.foods) in a menu and it works). I have an item in my refrigerator object but still, this code is not working.
Thank you for your time!