我刚刚开始创建一个(非常基本的,我刚接触到python)学生数据库,您可以插入学生和详细信息或查看学生及其详细信息。这是迄今为止的代码 -
name = []
age = []
year = []
chosen_subjects =[]
classroom=[]
seat_number=[]
comments=[]
student = [name, age, year, chosen_subjects, classroom, seat_number, comments]
print ("Welcome to Student Database")
print()
while True:
eorv = input("Press E to enter a new student or V to view existing students ")
print()
if eorv == "E" or "e":
ename = input("Enter student's name")
name.append(ename)
eage = input("Enter student's age")`
age.append(eage)
eyear = input("Enter student's year")
year.append(eyear)
echosen_subjects = input("Enter student's chosen subjects")
chosen_subjects.append(echosen_subjects)
eclassroom = input("Enter student's classroom")
classroom.append(eclassroom)
eseat_number = input("Enter student's seat number")
seat_number.append(eseat_number)
ecomment = input("Enter any comment about this student")
comments.append(ecomment)
这似乎是问题所在
elif eorv == "V" or "v":
print (student)
按下“V”时,它只询问“E”中的所有问题。我不确定为什么会这样,有人可以帮忙吗?
答案 0 :(得分:0)
您的问题与if和elif语句一致。这对我有用。
if eorv == "E" or eorv == "e":
你的elif也是如此
if eorv == "V" or eorv == "v: