0

I want to take input from users in the class. So I wrote class name(input()). it did not throw an error but when I tried to write 3 input separated by commas or by space then the error displayed was : init() missing 2 required positional arguments: 'rollno' and 'marks'" . In which format should I enter input? . And is this correct? I am pasting the code below.

class Course:
    def __init__(self,name,rollno,marks):
        self.name=name
        self.rollno=rollno
        self.marks=marks
        
        if rollno[0:3]=="B21" and len(rollno)==6 and marks<=100 and marks>=1:
            print("pass")
            if marks>=40:
                print("pass")
            else:
                print("fail")
        else:
            print("Invalid Input")
a=Course(input())
  • 1
    `input()` returns a single string. Your class expects 3 things to be passed to it. You need to find a way to split your input into 3 things & pass all of them to the class – rdas May 25 '21 at 08:05
  • 1
    Well how would you normally create a Course? I.e What else would you need if you did `Course("maths")` – Sayse May 25 '21 at 08:05

0 Answers0