jeudi 25 juin 2020

PYTHON - Break out of while loop when user enters a particular value [duplicate]

So I require to run a certain set of functions as given in the if statement and I want this code to keep on asking the user to enter the required conditions as given below until it enters 1(or 0) and the loop breaks.

d = 0
id d==0:
    
while (d!=1):

text = input("Enter: ").lower()

if text=='t':
    function1()
elif text =='i':
    function2()
else :
    print("Enter a valid input")
    
d=input("want to run again enter 0 for yes and 1 for no" )          


enter code here

Aucun commentaire:

Enregistrer un commentaire