Let's say I have an array
A=[1 2 3 2 4 5 6]
Now i need to store first 3 values of array A into array B
I am doing
b.append(a[1])
b.append(a[2])
b.append(a[3])
but I am unable to get any output.
You should consider to use slices
a = [1, 2, 3, 4, 5]
b = a[:3]
print b #print(b) for Python 3.x
Output:
[1, 2, 3]
b = a[:3]. Also, what do you mean by not getting any output?print(b)give you? And what do you expect to see?