I've been working on a command that returns a random string using a dictionary and the random library:
import random
randnum = random.randint(0,5)
words = {1:"random text" 2:"random text2" 3:"random text3" 4:"random text4" 5:"randomtext5"}
def getrandom():
randomtext = words[randnum]
return randomtext
But whenever I use the command it returns the same text since I'm getting the same number over and over again, I also tried using the random.sample
method, but I'm getting the same results, I don't have much experience with this library, Is there any way for me to get a random non-duplicate number? any help would be appreciated!
Aucun commentaire:
Enregistrer un commentaire