Y
Y
Yakovlev Daniil2021-07-16 13:58:36
Python
Yakovlev Daniil, 2021-07-16 13:58:36

How to make random variables not repeated?

def spam():
    messages_test = int(messages)
    time_test = int(time)
    for i in range(messages_test):
        result1 = random.choice(messages_list1)
        result2 = result1
        result3 = result2
        result4 = result3
        result5 = result4
        result6 = result5
        pwa.keyboard.send_keys (tag, with_spaces=True)
        sleep(time_test/4)
        pwa.keyboard.send_keys (result1, with_spaces=True)
        sleep(time_test/4)
        pwa.keyboard.send_keys ("{ENTER}")
        sleep(time_test/2)

I use the PYWINAUTO library so that it prints the text, and RANDOM so that it selects random text from the list, but these words are often repeated (there are 100+ values ​​in the list).
How to make sure that they do not repeat?
I want result2 to be equal to the previous value of result1, result3 to be equal to the previous result2 (and so on).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-16
@Kil0Gramm

Why is this at all?
numbers = random.sample(a, k=6)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question