Let's say there is a dictionary that has strings mixed with lists:
dictionary = {'item_a': 'one',
'item_b': 'two',
'item_c': ['three', 'four'],
'item_d': 'five'}
and the result should be:
['one', 'two', 'three', 'four', 'five']
How can it be achieved by using list comprehension?
The following gives only the values for the list, but it's missing the strings that are not a list and else does not work if added right after the if:
[val for sublist in dictionary.values() if type(sublist) is list for val in sublist]