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

Problem: Python I want a counter that increments no matter where I

# function

def triominoes(..., ...., ...):

# code

...

recursive_triominoes(..., counter, ..., ...)

return board

increment it within a class (i.e. inside functions, other functions, inside recursive

# 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!