Question
Problem : Python I want a counter that increments no matter where I increment it within a class (i.e. inside functions, other functions, inside recursive
Problem: Python
I want a counter that increments no matter where I increment it within a class (i.e. inside functions, other functions, inside recursive functions). The problem I'm running into is that when I enter recursion the counter resets.
Here is the barebones of my python class:
# global counter
counter = 1
# function
def triominoes(..., ...., ...):
# code
...
recursive_triominoes(..., counter, ..., ...)
return board
# Recursive function
def recursive_triominoes(..., counter = 1, ..., ..., ....):
# code
...
A_list = recursive_triominoes(..., counter, ..., ...) # counter goes from 1-5
B_list = recursive_triominoes(..., counter, ..., ...) # counter starts back at 1 again instead of continuing at 6
...
return board
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started