I am trying to pass arguments to a function from a list using threads in python (Note:The values to the function should not be hard-coded and all the elements of the list will be passed.) Please look at the sample code here:
from threading import Thread
list=['john','doe','srav','dev','app']
def m1(name,prefix):
for ele in range(2):
print(name +prefix)
def main1():
t1=Thread(target=m1,args=('abcd','john'))
t2 = Thread(target=m1, args=('abcd', 'doe'))
t1.start()
t2.start()
if __name__ == '__main__':
main1()
Here i hard-coded the values to the function ('john','doe')instead of that pass from the list and all the elements will be passed.