Variable referenced before assignment

I need to know how to fix this.

Repl link:

counter += 1


@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.


They can access it directly using (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.


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


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.