lundi 1 juillet 2019

why the input process cannot go back after else in python

so I have 2 input for my app, I want to show the inputs if my initial variable is not 0, you can see my code below

 ```python 
import random
init = 100
while init > 0:
  x = random.randint(0,24)
  a = int(input("input value a:"))
  if a < 25:
    b = int(input("input value b"))
    if b <= init:
      init -= b
    else:
      print("b should smaller than init")
  else:
    print("a should between 0 and 24")

when I run and put value a more than 25, I got the else a < 25, and redirect again to input value a, but when I put value b more than init, I got the else from b <= init but not redirect to input value b but to value a after while ? can someone help me, thank you

Aucun commentaire:

Enregistrer un commentaire