I have two list that can be list or None. I want to get third list with result of unique unite this two list.
- If
firstlist is None andsecondis None -resultwill be None - If
firstis None andsecondis not None -resultwill besecond - If
secondis None andfirstis not None -resultwill befirst - If
secondis not None andfirstis not None -resultwill befirst + second
I do this simple with if condition:
result = first if first else second
if result is not None:
try:
result = list(set(first + second))
except TypeError:
pass
I want to do this in better way. Maybe you know way to solve this by one or more string using itertools or something else.