I suspect I'm missing something super basic and just looking at this problem wrong so I would be happy if anyone could point me in the right direction. Here's my problem:
I have a list of variables and, for simplicity, they always contain the value. I want to have my code go through all the possible options. Here's the way I quickly thought to do it:
num_apples = 100
num_pears = 100
for current_apple in range(0,num_apples+1):
for current_pear in range(0, num_pears+1):
print current_apple, " - ", current_pear
The good thing about this code is I can break out of loops easily(i.e. say I don't want current_apple + current_pear > 50 or something), but the major drawback is I need to know specifically how many variables(fruits in this case) that I'm starting with and often I won't know.
Is there a way to dynamically create the for loop type structure above so I can control when to break a sub loop but without knowing specifically how many variables I'll have ahead of time?
EDIT: Ideally I think it would be easier for me, if I could increase the size of one variable at a time so I can break out of the loop once the variable get out of range that is useful to me.