How to use an array index to update a value in array.The compiler keep mention Index Error:list assignment index out of range.
Array Value before change:
[10,0,9,1]
Array value after update:
[9,0,9,1]
x = int(input("Input a number"))
drinkstock = [10,0,9,1]
z=int(drinkstock[x]-1)
for y in drinkstock:
if drinkstock.index(y)==x:
drinkstock[y]=z
print(y)