Add delay python random choice

please help, how do i add delay before thread change to the next

my code look like this :

import random
import time

 name1 = ['one', 'two', 'three'] 
 name2 = '123abc'   # this combination letter and number
sleep_in_seconds = 3

    n1 = str(name1)
    n2 = str (random.choice(name2))
    n3 = str (random.choice(name2))
        time.sleep(sleep_in_seconds)

        choice = (n1+n2+n3)
        finalchoice = foo(choice)

result script right now is :

one123abc
two112acc
three123abc

what i want , script result is :

one12b
one23c
one32a

#after 3 second, thread change to next value in **name1** list , so it will be
#itteration in "name2" list is not required.

two2b
two23c
two32a

after 3 second delay, thread change again to next value in  **name1** list 
#itteration in "name2" list is not required.

three2b
three23c
three32a

i have tried time.sleep , also event.wait
but still no luck, my code still wrong

:frowning:

Are you trying to do something like this?

# Do the imports
from random import choices
from time import sleep

# Some characters
characters = '123abc'


# Start a for loop with a list
for name in ['one', 'two', 'three']:
    # Start a second for loop to get 3 random characters
    for i in range(3):
        # Print results
        print(f'{name}{"".join(choices(characters, k=3))}')
    # Sleep for 3 seconds (This stops the script fpr 3 seconds)
    sleep(3)

    # For a blank/newline
    print()
    
    

thank you so much…!!!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.