No Repeats please Help [Solved]

Hi:
I came up with an algorithm for the challenge No Repeats please.
It can’t pass any tests while I always can get correct answer by manually running it. I am wondering if it is because it is so slow that I can’t pass the tests.
Below is my code. Anyone can help me please. Thanks!

It’s probably because you have a global variable count.

Yes. You are right.
I changed count to a local variable and it works. Thanks!
But do you know why the global variable doesn’t work?

See the first comment here: Global variable conflicts with algorithm. · Issue #9199 · freeCodeCamp/freeCodeCamp · GitHub

The reason being that we run multiple test cases in on the code, using a global var like this persists the last value and hence the test cases fail.