Variable referenced before assignment

Question:
I need to know how to fix this.

Repl link:
https://replit.com/@dft-fritz/math?v=1

counter += 1

image

@9pfs1 please look at this

You shared the repl URL in the screenshot. Also, Discourse (what Replit Ask uses) supports inline images, so an external image isn’t necessary.

2 Likes

They can access it directly using https://replit.com/@dft-fritz/math?v=1 (Here’s a screenshot, so you don’t have to log out to check):

1 Like

I don’t care if they look at it, I care I they mess with the code

People can’t edit your repls unless you invite them.

1 Like

Looks like you didn’t define the counter variable.

how would I do that?

Try defining counter on line 1, e.g.:

counter = 0
1 Like

Definitely not on line one, but inside of the multiply function.

2 Likes

It seems like i - 1 would work instead of needing a dedicated counter variable

2 Likes

I didn’t realize that it was a scoped thing at first.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.