I am trying to write a code that asks a user to enter a digit. If the entered digit matches the other digit (say, some stored number), then whatever message is printed. If it doesn't, then the user should try to enter a digit again. If I put 'input' function and assign it to a variable at the beginning of a while loop, the loop works perfectly. Now, if I use the input function outside the while loop and rather reference it by using another variable, my loop crashes and prints "please, try again" infinitely when the entered digit doesn't match the stored digit.
a = 3
b = input('enter a digit: ')
while True:
c = b
if a == c:
print('good')
else:
print('please, try again')
If I enter 4, the program prints "please, try again" infinitely.
My questions: 1) Why? 2) What can I do to make it work because I don't want to use input function in the while loop (my homework requires so)?