I’m working on a project in which I have to take
List as input from the user and work on it. Before working, I have to check that user doesn’t provide any nested
List. My code below is not working properly and giving me an error.
def is_aggregated(lst): return isinstance((item,list) for item in lst) #Creating a list my_list1 = [1, [2, 3], 4] my_list2 = [1, [2, [3, 4]], 5] #Checking nesting print(is_aggregated(my_list1)) print(is_aggregated(my_list2)) TypeError: isinstance expected 2 arguments, got 1