Hi :) I'm new to Python coding.
What I wanted for my codes to do is that
...when the user inputs a value greater than 1, then a text will be displayed saying "value should only be 1 or 0..." and then loops back to the line of input code until the user will input the valid response.
However, what my code is doing is that it registers the value greater than 1, displays the text - "value should only be 1 or 0...", and then continues on.
It seems that the else statement is not working.
counter = 1
for i in t:
if i == b[0]:
b.pop(0)
while True:
try:
while counter < 6:
print('VALUE', counter)
s = int(input())
counter += 1
break
if 2 > s >= 0:
print('VALUE', counter-1, '=', s)
break
else:
print('VALUE should be 1 or 0 in value...')
except ValueError:
print('Please provide only a value of 1 or 0 for VALUE...')
u.append(s)
Aucun commentaire:
Enregistrer un commentaire