0

Add student and Student Id in this program

while True: students = [] def get_students_titlecase(): students_titlecase = [ "name" ] 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 = 332): student = {"name":name ,"student_id":student_id} students.append(student) print("If you want to add students write 'YES' or If you not want to add students write 'NO'") add = input(":") if add == "YES": student_name = input("Enter the name:") student_id = int(input("Enter the student ID:")) add_student(student_name, student_id) print_students_titlecase() if add == "NO": break Please explain, why I'm not able to added student id

6th May 2018, 11:08 AM
Lakshman Patel
Lakshman Patel - avatar
2 Réponses
+ 2
Change line 7 to students_titlecase.append(student["name"].title() Then line after append the ID and you’ll get your ID you wanted, here’s my version with classes (which from your python progression you didn’t cover yet)... https://code.sololearn.com/caWMo2j8lvTl/?ref=app
6th May 2018, 11:45 AM
TurtleShell
TurtleShell - avatar
0
No, I learn only up to function
6th May 2018, 5:28 PM
Lakshman Patel
Lakshman Patel - avatar