vendredi 22 mai 2020

If condition not working properly and counter is not updating

Hey in the below code even if the "if" condition is not true it prints the value in if statement. how do i get to print "No matches found"

counter=0
print(": HOTEL NAME : ROOM NUMBER :  AIR CONDITIONING  : BREAKFAST  :  TELEVISION   : WIFI  : Cost/night($):")
for b in range(0,(n+2)):
    if(cost >= rooms1[b][6]):               
        print(rooms1[b])
        counter=1
ex=input("Press any key to continue..")
if(counter==0):
    print("No Hotels found accoeding to your budget")
    ex=input("Press any key to continue\n")

control is not going to the if (counter==0) even if the if statement is not true and counter is not set to 1.

if(counter==0):
    print("No Hotels found accoeding to your budget")
    ex=input("Press any key to continue\n")

Aucun commentaire:

Enregistrer un commentaire