I am creating a python code that have a function which should be run for number of times user asks using threads. Eg:
import time
T = input("Enter the number of times the function should be executed")
L = [1,2,3,4]
def sum(Num):
for n in Num:
time.sleep(0.2)
print("square:",n*n)
Based on the value of T from user, I want tho create T’ number of threads dynamically and execute the sum function in separate threads.
If user gives input as 4 then I need to create 4 threads dynamically and execute the same function with 4 different threads. Please help me out to create 4 multiple threads.Thanks!