Changing contents of an array
When you want to change a variable you can use code like this –
x = 4 x = 9 x = x + 1 print x
To change an array you need to access an individual element within the array first before you make a change.
numbers = [5,2,1,7,1] print numbers numbers[3] = 20 print numbers
Do you see that the 7 has changed into a 20? This is because 7 is at position 3 in the array (remember that it always starts from 0). Change the above code so that the 2 becomes a 90!
Output: (clear)











