Question: students = [ ] studentCount = 0 def addStudent ( studentCount ) : student _ id = input ( Enter student ID: )

students =[] studentCount =0 def addStudent(studentCount): student_id = input("Enter student ID: ") name = input("Enter student name: ") age = input("Enter student age: ") gpa = input("Enter student GPA: ") newstudent ={"id": student_id, "name": name, "age": age, "gpa": gpa } students.append(newstudent) # Append the variable, not a string return studentCount +1 def displayStudents(): if not students: print("No students to display.") else: for student in students: print(f"ID: {student['id']}, Name: {student['name']}, Age: {student['age']}, GPA: {student['gpa']}")
Now I get this NameError: name 'newstudent' is not defined. Did you mean: 'addStudent'? PLEASE HELP i have been at this alllll day I also keep getting this error
print(f"ID: {student['id']},Name: {student['name']},Age: {student['age']},GPA: {student['gpa']}")
TypeError: string indices must be integers, not 'str'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!