I just started with Python and programming, and I have a general question about storing many objects.
My understanding of objects is still this way: I can define an object like:
class Meal:
And there are functions on it so that I can find out about it, for example, Meal.drink returns "soda", and Meal.main returns "pizza". So far so good.
However, I'm not sure if I'm doing the right thing when it comes to storing a lot of objects. Right now, I keep them all on the list so that every time I want to record a new meal, I do:
temp = Meal()
listOfMeals.append(temp)
If I want to find out how many times I had soda in all the recorded meals, I sort through the list and count:
for each in listOfMeals
if each.drink == 'soda':
sodaCount = sodaCount + 1
? , - ( ), , - .
.