The check function has two parameters: param - the number of elements in the list and num - the list itself. First, we check whether the number of specified elements in the list matches the number that was entered by the user. Next, I have the following task: I have to see if there are identical elements in the list and delete one of them. I get the error IndexError: list index out of range in line 13. Help please, it is very necessary. Thank!
def check(param, num): if (param != len(num)): print(param) print(len(num)) return False else: a = len(num) for i in range(a): for j in range(a): if (i == j): continue else: if (num[i] == num[j]): num.pop(j) return num c = 9 d = [2, 1, 3, 2, 9, 1, 2, 3, 1] print(check(c, d))