I am trying to write a simple program that will allow me to control the location of the number 5 in an array. However, when I run the code the controls don't really work. Also, I'm trying to clear the terminal so that it only shows the current position, not the past ones, but even that doesn't work. Please help.
import numpy as np
import keyboard
from os import system
a = int(input())
c = int(input())
z = 0
isKEYPRESSED = 0
while (True):
b = np.zeros((a,c))
for i in range(a):
for j in range(c):
b[i][j]=0
b[z][0] = 5
print(b)
if keyboard.read_key() =="right" and isKEYPRESSED == 0:
b[z][0] = 0
z = z + 1
isKEYPRESSED = 1
if keyboard.read_key() =="right" and isKEYPRESSED == 1:
isKEYPRESSED = 0
if keyboard.read_key() =="left" and isKEYPRESSED == 0:
b[z][0] = 0
z = z - 1
isKEYPRESSED = 1
if keyboard.read_key() =="left" and isKEYPRESSED == 1:
isKEYPRESSED = 0
system('clear')