Question: How to raise own error when one positional argument is missing?I have this function that inserts a line at a given index called num.python will

How to raise own error when one positional argument is missing?I have this function that inserts a line at a given index called num.python will raise an error if no num is given but I want to raise my own error.How do I do that?This is what I tried.

def insertNum(self, num, line): if num== None: raise Exception("Num not specified.") else: self.list.insert(num, line) return self.list

But it doesn't work pleaseee helpp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!