Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

No duplicate digits

CodingGoose
CodingGoose

Hi I'm making a game and I need to generate a 4 digit number.
I wrote
random.randint(1000,9999)
so that I get a 4 digit number, but I need the number to have no duplicate digits (ex. 7827 has 7 twice)

3 years ago

Voters

Comments

TopNew
1
CodingCactus
CodingCactus

I can tell you soon, I have to have lunch now :)

3 years ago
1
CodingGoose
CodingGoose

@CodingCactus
Thanks! :)

3 years ago
1
CodingCactus
CodingCactus

@DannyIsCoding
basically, add the randNum function to your repl, then replace your random.randint(1000,9999) with randNum(1000,9999)

3 years ago
1
CodingCactus
CodingCactus

@DannyIsCoding
is this for your goose game btw?

3 years ago
1
CodingGoose
CodingGoose

@CodingCactus
Yes. It's coming out in 15mins or so :)

3 years ago