Sep-19-2019, 01:38 PM
Hi,
I have function in which I am passing multiple lists. Now, I want to access (or assign to another variable) the lists (given as arguments in function) by its name. I tried below code, but its giving error.
I have function in which I am passing multiple lists. Now, I want to access (or assign to another variable) the lists (given as arguments in function) by its name. I tried below code, but its giving error.
#%% passing multiple lsit to function def my_func(list1,list2,list3): return list1,list2,list3 p1 = my_func(list1 = ['BNKL', 'KPUI', 'HYNI'],\ list2 = ['Ty'],\ list3 = [6, 7, 8]) print(" The first list : ", p1[0]) print(" The second list : ", p1[list1]) l_l1 = p1[1]Error:
The first list : ['BNKL', 'KPUI', 'HYNI'] Traceback (most recent call last): File "<ipython-input-2-30d2f38dbdd7>", line 6, in <module> print(" The second list : ", p1[list1]) NameError: name 'list1' is not defined