Apr-30-2020, 09:27 PM
Hi,
what is the more effective way of the both below?
Or is there a third variant?
what is the more effective way of the both below?
Or is there a third variant?
def add_only_once_to_list(in_obj, in_list,): if in_obj not in in_list: in_list.append(in_obj)Or with a local set:
def add_only_once_to_list(in_obj, in_list,): temp_set = set(in_list) temp_set.add(in_obj) in_list = list(temp_set)