samedi 9 septembre 2017

Why is the if statement not executed?

so i have an assignment here where i have to ask the user if it wants to add a new student to the program or not so i set a variable to hold the user command and then see , if its Yes (1) the program will ask the user to enter a name and id , if not , program exit

here is the code

students = []

def get_students_titleCase():
    students_titleCase = []
    for student in students:
        students_titleCase = student["name"].title()
    return students_titleCase

def print_students_titlecase():
    students_titleCase = get_students_titleCase()
    print(students_titleCase)

def add_student(name , student_id = 000):
    student = {"name" : name , "student_id": student_id }
    students.append(student)

user_command = input("Do You Want to Add a Student Name?\n1- Yes\n2- No\n")
#user_command = 1
if user_command == 1:
    student_list = get_students_titleCase()
    student_name = input("Enter Student Name: ")
    student_id = input("Enter Student ID: ")
    add_student(student_name, student_id)
    print_students_titlecase()

Aucun commentaire:

Enregistrer un commentaire