Print numbers with a delay

Report a typo

Write a program that creates two threads that each print numbers 1-5 with a delay.

The result of the program would be something like this:

Thread-1: 1
Thread-2: 1
Thread-1: 2
Thread-1: 3
Thread-2: 2
Thread-1: 4
Thread-1: 5
Thread-2: 3
Thread-2: 4
Thread-2: 5

Fill in the blanks to complete the program.

Fill in the gaps with the relevant elements
import 
import time

def print_numbers(thread_name, delay):
    count = 0
    while count < :
        time.(delay)
        count += 1
        print(f"{thread_name}: {count}")

try:
    .start_new_thread(print_numbers, ("Thread-1", 1,))
    _thread.(print_numbers, ("Thread-2", 2,))
except:
    print("Error: unable to start thread")

thread_thread5sleeptimestart_new_thread_thread

Create a free account to access the full topic