0

=========================================================================

def updateCourses(self, name = '', hours = 0, grade = ''):

      gradeDict = {'A': 4, 'A-': 3.7, 'B+': 3.3, 'B': 3, 'B-': 2.7, 'C+' :            2.3,\
                    'C': 2, 'C-': 1.7, 'D+': 1.3, 'D': 1, 'D-': 0.7, 'F': 0}

      course = {}
      course['name'] = name
      course['hours'] = hours
      course['grade'] = grade

      self.courses.add(course)

      if not name:
         name = input("Enter course number:")
         print(name)

      if not hours:
         hours = int(input("Enter hours for:", name))
         print(hours)

      if not grade:
         grade = input("Enter hours for:", name).upper()
         print(grade)
         score = gradeDict[grade]

      course = (name, hours, grade, score)
      self.classList.append(course)

      self.totalHours += hours
      self.qualityPoints += hours * score
      self.GPA = self.qualityPoints / self.totalHours

sorry i'm newbies. it return "Traceback (most recent call last):

File "C:\Users\Abee\Desktop\GCSE\test.py", line 157, in <module>
addCourses(studentList)
File "C:\Users\Abee\Desktop\GCSE\test.py", line 111, in addCourses
Student.updateCourses()
TypeError: updateCourses() missing 1 required positional argument: 'self' thanks for helping me
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
  • This does not appear to be the code listed in the trace. Regardless, the error is fairly self explanatory: you need to call `updateCourses` as `self.updateCourses(...)`. – user2085282 Oct 26 '15 at 03:29
  • When you call a method from an instance the self variable (or instance) is passed implicitly as self. However, you are calling the updateCourses method from the class (Student) instead of an instance so the argument self is not being passed and therefore the TypeError is being thrown. – Colin Schoen Oct 26 '15 at 03:30

0 Answers0