that would be the better approach.
However you should know that
However you should know that
list
is a mutable type, and you can change the list elements inside the function without using globalmy_list = [1, 2] def change_list(): my_list[0] = 3 my_list[1] = 4 change_list() print(my_list) def change_list1(some_list): some_list[0] = 10 some_list[1] = 11 change_list1(my_list) print(my_list) def change_list2(): return [5, 6] my_list = change_list2() print(my_list)
Output:[3, 4]
[10, 11]
[5, 6]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs