Reputation: 3318
I have a file which I had converted into an array. File looks like this:
When I print results I get these values:
# Example A
a=gift_costs
print(a)
[ 8 84 42 ... 59 12 12]
# Example B
b=gift_costs[gift_costs]
print(b)
[78 48 92 ... 80 23 23]
Example A prints the good results. But Example B no. Why? What do I have to google to know the answer?
Upvotes: 1
Views: 70
Reputation: 40628
You are indexing array a
(it's also gift_costs
) with itself, i.e. the resulting array b
would be characterized by this loop:
for i in range(len(a)):
b[i] = a[a[i]]
Upvotes: 2