'different between append list to array python [closed]
Had a question regarding appending to python list. See below
arr1 = []
arr2 = [1,2,3,4,5]
# Method 1
arr1.append(arr2)
# Method 2
arr1.append(list(arr2))
What is the difference between the both append methods above? I ran the above snippet in the python and saw the same results for both as arr1 prints [1,2,3,4,5].
Would it differ when you were to pass the list into a function and perform the same operations?
How to determine when to use # Method 1 or # Method 2?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
