Aggie Joseph February 2016

Why is the code not allowing the list to print?

Ive just started making a (very basic, im new to python) student database which you can insert students and details or view students and their details. Here's the code so far -

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)

This seems to be where the problem is

    elif eorv == "V" or "v":
        print (student)

When "V" is pressed, it just asks all the questions from "E". Im not sure why this is, can someone help?

Answers


Phil February 2016

Your problem looks to be with your if and elif statements. This works for me.

if eorv == "E" or eorv == "e":

Same goes for your elif

if eorv == "V" or eorv == "v:

Post Status

Asked in February 2016
Viewed 1,716 times
Voted 9
Answered 1 times

Search




Leave an answer