def copy_list(t):
try:
if type(t) is list:
t_copy=[]
n=len(t)
i=0
while i<n:
t_copy.append(t[i])
i+=1
return t_copy
except TypeError:
return "Not a list"
The problem says that I should write a function which takes a list of integers as an input and returns a copy of it. It should raise an exception if the input is not a list. I am unable to understand that why my code is unable to raise an exception if the value is not of the list type or when the input is None?