I tried the following;
a = [3, 2, 1]
a = a - 1
then, a contained [3, 2, 1, 0]
but, if I did the following;
b = “hello everybody”
b[“body”] = “one”
then, b contained “hello everyone”
I can understand that a is an array holding numbers and when I do a
it is performing an operation on element 4, while b is an array
holding characters and when I do a b[“body”] it seeks out the part of
that string containing “body” and does an operation on it.
So, to do an operation on 3 in array a, I tried doing a[“3”] = 4 which
gave an error as expected.
I’m a bit confused about this whole array thing, could someone please
elaborate on the above two different results for array operations?
Also, how would I seek an element in a numeric array without referring
to its index?