I'm just starting to use classes in python and am having a couple issues.
My first class and it's constructor just for reference for spot I'm having issues with:
class Course:
def __init__(self, number, credit,grade):
self.number = str(number)
self.credit= int(credit)
self.grade= str(grade)
Here's where I'm having issues. When I run it, it comes up and tells me that " names "Course" is not defined". Why would that be? Also I'm trying to initially create an empty list in init to add to later. In my str function I'm trying to iterate through the values I have in Course and create a string out representation in the format of ( example of out put):
Transcript:
English: credit 4, grade A
Math:credit 3, grade C
What I've been working with so far for my second class:
class Transcript:
courses = []
def __init__(self):
self.courses = Courses()
def __str__(self):
s = ""
i = 0
while (i < 10):
s += self.courses[i].__str__()
retu s
def __repr__(self):
retu str(self)
I feel it's probably obvious what I should be doing, but I'm very iffy on OOP since I just started leaing it this week.
