vendredi 27 novembre 2015

Python Class If Statement Not Working

Whenever I run this class (included the applicable section of code):

def setLevel(self, level):
    if (self.__level == "Freshman" or self.__level == "Sophomore" or self.__level == "Junior" or self.__level == "Senior"):
        self.__level = level
    else:
        raise ValueError("Level must be Freshman, Sophomore, Junior, or Senior")

through this section of the driver class.

undergraduate = Undergraduate("Jonathan", "Zhang", "214-000-0000", Address("611 Leon", "Austin", "Texas", 78705), "234-56-7890", "student@utexas.edu", 2300106, "Management Information Systems", 3.95, "Loser")

I am allowed to use a string not included in the if statement. If I need to post anymore parts of the code, I can.

Aucun commentaire:

Enregistrer un commentaire