mardi 3 août 2021

Why is my if statement not working (Python) [duplicate]

I have put together this code. It should assess if inserted value of value_a is in the range between 0 and 10. If yes the code should finish, if not, it should keep asking user to insert number within 0 and 10. But my if statement seems not to be working and it just keep looping that value is not within the range even if I insert correct value. Can anyone please help?

counter = 0
value_a=input("Insert value between 0 and 10:")

while counter == 0: 
   
   if value_a not in range(0,10):
      print(f"{value_a} is not in range between 0 and 10.")
      value_a = input("Insert again value between 0 and 10:")
   else:
        print(f"{value_a} is in range between 0 and 10.")
        counter += 1

Aucun commentaire:

Enregistrer un commentaire