Students become teachers - for the record


#1

Hi does anyone know why this isn’t being accepted? Thanks

lloyd = {
  "name": "Lloyd",
  "homework": [90.0, 97.0, 75.0, 92.0],
  "quizzes": [88.0, 40.0, 94.0],
  "tests": [75.0, 90.0]
}
alice = {
  "name": "Alice",
  "homework": [100.0, 92.0, 98.0, 100.0],
  "quizzes": [82.0, 83.0, 91.0],
  "tests": [89.0, 97.0]
}
tyler = {
  "name": "Tyler",
  "homework": [0.0, 87.0, 75.0, 22.0],
  "quizzes": [0.0, 75.0, 78.0],
  "tests": [100.0, 100.0]
}
students = [lloyd, alice, tyler]

for students in students:
  print students["name"]
  print students["homework"]
  print students["quizzes"]
  print students["tests"]

FAQ: Learn Python: Student Becomes the Teacher - For the Record
#2

because now after the loop you no longer have access to the list:

for students in students:
  print students["name"]
  print students["homework"]
  print students["quizzes"]
  print students["tests"]
  
print students

which will cause bugs further down the line


#3

Ok thank you, I will go fix that now


#4

using the same iterator name as the iterable (list in this case), is bad practice, it cause undesired effects, i think its a good thing the exercise rejects your code


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.