Question: students = [ John Smith Abby Johnson Peter Smith Paisley White Fayth Holland Kolton MacDonald ] studentCount = 0 def addStudent ( ) : student

students =[
"John Smith"
"Abby Johnson"
"Peter Smith"
"Paisley White"
"Fayth Holland"
"Kolton MacDonald"
]
studentCount =0
def addStudent():
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')
studentCount +=1
print("Student added successfully.")
def displayStudents():
for student in students:
print(f"ID: {student['id']}, Name: {student['name']}, Age: {student['age']}, GPA: {student['gpa']}")
I keep getting this error code for the last part
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!