mercredi 7 décembre 2016

Python Continue onto the next Elif Statement

My current code searches through a list of tuples and it will print the entries that match the entered string. If it cannot find the string it will print an error. However my code prints the error even after printing the results found.

if choice == 1:
            scheme=input("Enter the degree scheme: ").upper()
            for i in lst:
                if i[2] == scheme:
                    printStud(i[0:5])

            if scheme not in i:
                    print("Could not find a record with degree scheme",scheme)

How would i change this so it will find all the entries of the for loop, and if none are found it shows the error. Because currently it shows the entries found then also the "Could not find.." error.

Aucun commentaire:

Enregistrer un commentaire