如果语句返回错误状态

时间:2018-12-15 23:14:03

标签: python python-3.x class if-statement

我在此代码无法正常工作方面遇到麻烦:

class Student:

def __init__(self, full_name, grade_level, grade_1, grade_2, grade_3):
    self.name = full_name
    self.gl = grade_level
    self.grade_1 = grade_1
    self.grade_2 = grade_2
    self.grade_3 = grade_3

def find_counselor(self, full_name):
    fname = list(self.name)
    for i in range(len(fname)):
        print(i)
        if fname[i] == " ":
            if fname[i+1] == "A" or "B" or "C" or "D" or "E" or "F" or "G":
                print(full_name, "'s counselor is Camille Nix.")
            elif fname[i+1] == "H" or "I" or "J" or "K" or "L" or "M" or "N" or "O" or "P":
                print(full_name, "'s counselor is Gay Myrick.")
            elif fname[i+1] == "Q" or "R" or "S" or "T" or "U" or "V" or "W" or "X" or "Y" or "Z":
                print(full_name, "'s counselor is Kerri Curcoe.")

person = Student
person("Bill Taylor", "Sophomore", 99, 99, 99).find_counselor("Bill Taylor")

学生姓氏的第一个字母应该确定学生去找哪位辅导员,但是无论我输入什么名字作为学生的名字,它总是以Camille Nix的身份返回给我。我不确定为什么会这样。非常感谢您的帮助。

0 个答案:

没有答案