Function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Function

my_list=["a","b","c","d","e"] def my_new_list(new_list): how should I write the code further so that I get the same elements in new_list as in my_list when I call the function???

28th Feb 2017, 4:31 AM
Sk Maidur
Sk Maidur - avatar
6 Answers
+ 1
new_list = my_list print (new_list)
28th Feb 2017, 4:57 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
0
U'll get this list at runtime if you call your function with your "my_list" as argument. --- my_new_list(my_list) --- All operations in function will work with "my_list".
28th Feb 2017, 5:22 AM
Tony Loa
Tony  Loa - avatar
0
@raj it works ..but not when I use it in function
28th Feb 2017, 7:08 AM
Sk Maidur
Sk Maidur - avatar
0
what you getting wrong ? shre you code link please
28th Feb 2017, 9:53 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
0
@star lord & tony... u guys are right..if I take my_list as an argument ... but I want to use new_list as an argument
28th Feb 2017, 5:03 PM
Sk Maidur
Sk Maidur - avatar
0
ok, use two parameters my_new_list(my_list, new_list)
28th Feb 2017, 5:51 PM
Tony Loa
Tony  Loa - avatar