Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

# function

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

# code

...

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

return board

image text in transcribed

# 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. What information would the team members need?

Answered: 1 week ago