Dec-23-2018, 07:37 PM
So sorry, I'm a beginner with programming and I face something in lists confused me.
I know that when I concatenate 2 lists with (+) I create a new list.
I'm using Python 2.7
but where I put this in a procedure I don't get the same result
Why that?
another question why I get "none" message when I try to print
and print directly the procedure
I know that when I concatenate 2 lists with (+) I create a new list.
I'm using Python 2.7
list1 = [1,2,3] list1 = list1 + [4,5] print list1here I get list1 = [1,2,3,4,5]
but where I put this in a procedure I don't get the same result
list2 = [3,4,5] def mylist(my_list): my_list = my_list + [6,7] mylist(list2) print list2here I get list2 = [3,4,5]
Why that?
another question why I get "none" message when I try to print
print mylist(list2). What is the difference between calling the procedure then print it
mylist(list2) print list2
and print directly the procedure
print mylist(list2)