Hello, I have a problem with this code, it says 'Alumno' object is not iterable, ¿what do i need to do to fix this problem?, thanks in advance.
PS: I cant modify anything below "#Declaracion de datos" since in the problem i'm supposed to just make a class with objects(like A1=Alumno(data[1]), A2=Alumno(data[2], and so on) and methods to do certain mathematical operations with the data.
Python:
def Igual_Promedio(a, b):
return sum(a) / 3 == sum(b) / 3
class Alumno:
def __init__(self, data):
self.data = i
# Declaracion de datos
data = []
data.append(["J Araneda", 1.0, 3.0, 7.0])
data.append(["K Bahamondes", 4.0, 4.0, 4.0])
data.append(["J Carrasco", 3.0, 3.0, 3.0])
data.append(["H Diaz", 3.0, 4.0, 5.0])
data.append(["I Elgueta", 6.0, 4.0, 3.5])
data.append(["J Faundez", 5.0, 4.5, 6.5])
data.append(["G Gutierrez", 4.0, 5.0, 5.5])
data.append(["F Hernandez", 5.0, 4.6, 4.5])
data.append(["H Isla", 6.0, 6.0, 6.0])
data.append(["A Jodorowsky", 7.0, 4.7, 6.1])
############################
A = []
for i in data:
tmp = Alumno(i)
A.append(tmp)
print(Igual_Promedio(A[0], A[8]))
PS: I cant modify anything below "#Declaracion de datos" since in the problem i'm supposed to just make a class with objects(like A1=Alumno(data[1]), A2=Alumno(data[2], and so on) and methods to do certain mathematical operations with the data.
Last edited: