Danny: I appreciate your point, but these are just for little code loops, nothing I need to hold on to, like the snippet above: I'm just trying to wrap a few things into one loop, which gives me flexibility about expanding/contracting the stats, for example, that I print (by changing the range list for "func"). Here's another code example, from my recent masterpiece:
def print_candl_info(garray): game_array, chute_nums, ladder_nums = {}, chutes, ladders list_index = 3 for i in chute_nums.keys(): chute_nums[i] = 0 # zero all values for i in ladder_nums.keys(): ladder_nums[i] = 0 for clkeys in ["chute_nums", "ladder_nums"]: # increment candl values list_index += 1 # horrible kluge: must be 4 for chutes, 5 for ladders below for corl in eval(clkeys): for game in garray: if corl in game[list_index]: eval(clkeys)[corl] += 1 print("total ", clkeys, "= ", sum(list(eval(clkeys).values()))) For the purposes of answering this question, ignore the horrible kluge. Though if you have any suggestions on that point, I'm still all ears. Since I couldn't figure out the right way to do that, I left it as more or less the most unforgivable kluge I could find, so I won't be able to sleep until I improve on it. Suggestions are welcome. If it's not obvious, it relies on the fact that the clkeys iterates precisely twice. It might be that the answer lies in rearranging my data structure... I'm about to post the entire program again for any comments, once I clean it up just a BIT more, so if it's not obvious don't worry about it. game = [int, int, int, int, [], []] # game[4] = chutes, game[5] = ladders
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor