Я создал новый класс:
testing.py:
class student:
def __init__(self, name, major, gpa):
self.nm = name
self.mj = major
self.gp = gpa
, затем я перехожу к своему рабочему файлу testing.py:
from testing import student
student1=student("Marcos","Physics",3.99)
student2=student("Phillyp","Biology",2.99)
student3=student("Naim", "Architecture", 3.42)
for k in range(1,4):
print(student(k).gp) <------- how do I merge this string with int!?!?
Моя конечная цель - распечатать ВСЕ gpa всех студентов, поэтому я знаю, что мне нужно сделать
print(student1.gp)
print(student2.gp)
print(student3.gp)
Итак, как мне объединить k в имя переменной, чтобы создать student1.gp, student2.gpи т. д.
Большое вам спасибо!