I have a while loop. The purpose of this while loop is to trivially decide if a given integer N exists at a given index location of M.
I can achieve a better space complexity if I only used one line for each request of an input. Arbitrarily giving one element at a time instead of an entire list.
M = 2
N = 2
index = -1
while True:
   
   print('take input: ', end = "")
   a = str(input())
   index = index + 1
   if int(a) == N:
       if index == M:
           print('yes')
           break
   if index > M:
       print('no')
       break
   if index < M:
       if int(a) == N:
           print('no')
           break
Unintended result
================= RESTART: C:\Users\User\Desktop\logspace(m).py ================
take input: 1
take input: 2
no
>>> 
I would like the console to only do one line at a time as shown below.
================= RESTART: C:\Users\User\Desktop\logspace(m).py ================
take input: (Do not echo previous inputs only one integer at a time... All on one line!)
no
>>> 
Question
Is there any functions, modules, etc that could do this without tinkering with my console settings?
